public IHttpActionResult Get(string id) { var item = context.Tbl_PreEmployee.Where(p => p.EmployeeID == id).FirstOrDefault(); if (item == null) { return(StatusCode(HttpStatusCode.NoContent)); } else { Tbl_PreEmployee cat = new Tbl_PreEmployee(); cat.ID = item.ID; cat.EmployeeID = item.EmployeeID; cat.FirstName = item.FirstName; cat.LastName = item.LastName; cat.BirthDate = item.BirthDate; cat.DepartmentID = item.DepartmentID; cat.PresentAddress = item.PresentAddress; cat.PermanentAddress = item.PermanentAddress; cat.Phone = item.Phone; cat.Email = item.Email; cat.Sex = item.Sex; cat.Nationality = item.Nationality; cat.Religion = item.Religion; cat.MaritalStatus = item.MaritalStatus; cat.BloodGroup = item.BloodGroup; cat.JoiningDate = item.JoiningDate; cat.SalaryCategoryID = item.SalaryCategoryID; cat.Password = item.Password; cat.Picture = item.Picture; cat.Type = item.Type; cat.Status = item.Status; cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts", Method = "GET", Rel = "Self" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "GET", Rel = "Specific Resource" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "PUT", Rel = "Resource Edit" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "DELETE", Rel = "Resource Delete" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts", Method = "POST", Rel = "Resource Create" }); return(Ok(cat)); } }
public IHttpActionResult Get() { var list = context.Tbl_PreEmployee.ToList(); List <Tbl_PreEmployee> categories = new List <Tbl_PreEmployee>(); foreach (var item in list) { Tbl_PreEmployee cat = new Tbl_PreEmployee(); cat.ID = item.ID; cat.EmployeeID = item.EmployeeID; cat.FirstName = item.FirstName; cat.LastName = item.LastName; cat.BirthDate = item.BirthDate; cat.DepartmentID = item.DepartmentID; cat.PresentAddress = item.PresentAddress; cat.PermanentAddress = item.PermanentAddress; cat.Phone = item.Phone; cat.Email = item.Email; cat.Sex = item.Sex; cat.Nationality = item.Nationality; cat.Religion = item.Religion; cat.MaritalStatus = item.MaritalStatus; cat.BloodGroup = item.BloodGroup; cat.JoiningDate = item.JoiningDate; cat.SalaryCategoryID = item.SalaryCategoryID; cat.Password = item.Password; cat.Picture = item.Picture; cat.Type = item.Type; cat.Status = item.Status; cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts", Method = "GET", Rel = "Self" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "GET", Rel = "Specific Resource" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "PUT", Rel = "Resource Edit" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts/" + cat.EmployeeID, Method = "DELETE", Rel = "Resource Delete" }); cat.links.Add(new Links() { HRef = "http://localhost:57254/api/Posts", Method = "POST", Rel = "Resource Create" }); categories.Add(cat); } return(Ok(categories)); }
public ActionResult EmployeeRegister(Tbl_PreEmployee tbl, Tbl_Accounts1 tbl1, HttpPostedFileBase file) { string pic = null; if (file != null) { pic = System.IO.Path.GetFileName(file.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/TeacherImage/"), pic); file.SaveAs(path); } tbl.Picture = pic; _unitOfWork.GetRepositoryInstance <Tbl_PreEmployee>().Add(tbl); /* * tbl1.UserID = tbl.EmployeeID; * tbl1.Password = tbl.Password; * tbl1.Email = tbl1.Email; * tbl1.Type = tbl.Type; * * _unitOfWork.GetRepositoryInstance<Tbl_Accounts>().Add(tbl1);*/ return(RedirectToAction("Index")); }
public IHttpActionResult Put([FromUri] string id, [FromBody] Tbl_PreEmployee item) { var cat = context.Tbl_PreEmployee.Where(p => p.EmployeeID == id).FirstOrDefault(); if (cat == null) { return(StatusCode(HttpStatusCode.NoContent)); } else { cat.ID = item.ID; cat.EmployeeID = item.EmployeeID; cat.FirstName = item.FirstName; cat.LastName = item.LastName; cat.BirthDate = item.BirthDate; cat.DepartmentID = item.DepartmentID; cat.PresentAddress = item.PresentAddress; cat.PermanentAddress = item.PermanentAddress; cat.Phone = item.Phone; cat.Email = item.Email; cat.Sex = item.Sex; cat.Nationality = item.Nationality; cat.Religion = item.Religion; cat.MaritalStatus = item.MaritalStatus; cat.BloodGroup = item.BloodGroup; cat.JoiningDate = item.JoiningDate; cat.SalaryCategoryID = item.SalaryCategoryID; cat.Password = item.Password; cat.Picture = item.Picture; cat.Type = item.Type; cat.Status = item.Status; return(Ok(item)); } }
public IHttpActionResult Post([FromBody] Tbl_PreEmployee preEmployee) { context.Tbl_PreEmployee.Add(preEmployee); context.SaveChanges(); return(Created(Url.Link("GetPreEmployeeById", new { id = preEmployee.EmployeeID }), preEmployee)); }