public void PutEmp(int id, Emp emps) { emps.Id = id; if (!repository.Update(emps)) { throw new System.Web.Http.HttpResponseException(HttpStatusCode.NotFound); } }
public int Upsert(Entity.Employee employee) { if (employee.Id == Guid.Empty) { return(_empRepository.Add(employee)); } return(_empRepository.Update(employee)); }
public IActionResult Edit(EmployeeEditViewModel emp) { if (ModelState.IsValid) { var input = _empRepository.GetEmployee(emp.Id); input.Name = emp.Name; input.EmailId = emp.Email; input.Department = (EmployeeManagement.DataAccess.Dept)emp.Department; //If the user has uploaded a new picture, update the details if (emp.Photo != null) { //Delete the old picture if the user uploads a new picture if (emp.ExistingPhotoPath != null) { string filePath = Path.Combine(hostingEnvironment.WebRootPath, "Images", emp.ExistingPhotoPath); System.IO.File.Delete(filePath); } string uniqueFilename = ProcessPhoto(emp); input.PhotoPath = uniqueFilename; } var updatedEmp = _empRepository.Update(input); //DataAccess.Repository.EmployeeModel --> EmployeeEditViewModel var model = new EmployeeEditViewModel { Id = updatedEmp.Id, Name = updatedEmp.Name, Email = updatedEmp.EmailId, Department = (KudVenvat1.Models.Dept)updatedEmp.Department, ExistingPhotoPath = updatedEmp.PhotoPath }; return(RedirectToAction("Details", new { id = model.Id })); } else { return(View()); } }
public async Task Put(int id, [FromBody] Employee model) { await repos.Update(id, model); }