public class EmpDTO
{
public int EmpNo { get; set; }
public string EmpName { get; set; }
public int Salary { get; set; }
public string DeptName { get; set; }
public string Designation { get; set; }
}
/*API*/
public class EmpCls:IEmpCls
{
public EmpDTO GetEmployee(string EmpName)
{
using (GeesemedLocalEntities DB = new GeesemedLocalEntities())
{
var Module = from p in DB.GetEmpDetails("")
where p.EmpName.Contains(EmpName)
select new EmpDTO
{
EmpName=p.EmpName,
Salary=p.Salary,
DeptName=p.DeptName,
Designation=p.Designation
};
return Module.SingleOrDefault();
}
}
}
interface IEmpCls
{
EmpDTO GetEmployee(string EmpName);
}
/*API Controller*/
[RoutePrefix("api/EmpApi")]
public class EmpApiController : ApiController
{
static readonly IEmpCls EmpRep = new EmpCls();
[Route("GetEmpDetails")]
public HttpResponseMessage GetEmpDetails(string EmpName)
{
EmpDTO objEmpDTO = EmpRep.GetEmployee(EmpName);
if (objEmpDTO == null)
{
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Sorry Not Call This Method");
}
else
{
return Request.CreateResponse
}
}
/*MVC Controller*/
public ActionResult GetEmployee()
{
return View();
}
public ActionResult GetEmployee(EmpDTO objDTO)
{
var client = new HttpClient();
if (objDTO.EmpName != null)
{
var response = client.PostAsJsonAsync("http://localhost:6198/api/EmpApi/GetEmpDetails", objDTO).Result;
if (response.IsSuccessStatusCode)
{
}
}
return View();
}
/*View*/
@model SampleMapper.EmpDTO
@{
ViewBag.Title = "GetEmployee";
}
GetEmployee
@using (Html.BeginForm("GetEmployee", "Emp", FormMethod.Post, new { id = "frmEmp" }))
{
@Html.ValidationSummary(true)
@Html.TextBoxFor(model => model.EmpName, new { tabindex = 1, maxlength = 10, @class = "form-control", placeholder = "EmpName", id = "EmpName" })
}
}
Jayraj GoswamiPosted Feb 20, 2016, 2:10 AM
public MST_Projects Add(MST_Projects project)
{
using (TicketSystemEntities DB = new TicketSystemEntities())
{
DB.Configuration.ProxyCreationEnabled = false;
DB.Configuration.LazyLoadingEnabled = false;
if (project == null)
{
throw new ArgumentNullException("item");
}
DB.SP_InsertUpdateProjects(0, project.ProjectName, project.ProjectVer, project.Active, project.Created_by, OutputParamValue);
DB.SaveChanges();
project.ProjectID = Convert.ToInt32(OutputParamValue.Value);
return project;
}
}
Jayraj GoswamiPosted Feb 20, 2016, 1:28 AM
.Content.ReadAsAsync
>().Result;
ViewBag.FillTicketStatus = FillTicketStatus.Where(item => item.Active == true);
Jayraj GoswamiPosted Feb 18, 2016, 7:32 AM
{
client.BaseAddress = new Uri("http://localhost:6198/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/EmpApi/GetAllByList/").Result;
if (!response.IsSuccessStatusCode)
{
// Error Over Here....!!
return View("Error");
}
var objtDTO = response.Content.ReadAsAsync
return View();
}
Chandu KumawatPosted Feb 17, 2016, 7:56 AM