// PUT: api/Employees/5 public IHttpActionResult Put(Employee employee) { if (ModelState.IsValid) { if (context.Jobs.Contains(employee.Job)) { if (context.Employees.Contains(employee.Manager)) { if (context.Departments.Contains(employee.Department)) { var dbemployee = context.Employees.Find(employee.EmployeeId); if (dbemployee != null) { Mapper.Map(employee, dbemployee); return(Ok(context.SaveChanges())); } return(NotFound()); } return(BadRequest("Departamentul nu exista!")); } return(BadRequest("Managerul nu exista!")); } return(BadRequest("Jobul nu exista!")); } return(BadRequest()); }
// PUT: api/Employee/5 public IHttpActionResult Put(Employee employee) { var dbEmployee = context.Employees.Find(employee.EmployeeId); if (dbEmployee != null) { Mapper.Map(employee, dbEmployee); return Ok(context.SaveChanges()); } return NotFound(); }
// PUT: api/Jobs/5 public IHttpActionResult Put(Job job) { if (ModelState.IsValid) { var dbjob = context.Jobs.Find(job.JobId); if (dbjob != null) { Mapper.Map(job, dbjob); return(Ok(context.SaveChanges())); } return(NotFound()); } return(BadRequest()); }
// PUT: api/Department/5 public IHttpActionResult Put(Department department) { var dbDepartment = context.Departments.Find(department.DepartmentId); if (dbDepartment != null) { Mapper.Map(department, dbDepartment); return(Ok(context.SaveChanges())); } return(NotFound()); }
// PUT: api/Location/5 public IHttpActionResult Put(Location location) { var dbLocation = context.Locations.Find(location.LocationId); if (dbLocation != null) { Mapper.Map(location, dbLocation); return(Ok(context.SaveChanges())); } return(NotFound()); }
// PUT: api/Locations/5 public IHttpActionResult Put(Location location) { if (ModelState.IsValid) { var dblocation = context.Locations.Find(location.LocationId); if (dblocation != null) { Mapper.Map(location, dblocation); return(Ok(context.SaveChanges())); } return(NotFound()); } return(BadRequest()); }
// PUT api/<controller>/5 public IHttpActionResult Put(Job job) { Mapper.CreateMap <Job, Job>(); var dbJob = context.Jobs.Find(job.JobId); if (dbJob != null) { Mapper.Map(job, dbJob); /* dbJob.JobTitle = job.JobTitle; * dbJob.MaxSalary = job.MaxSalary; * dbJob.MinSalary = job.MinSalary;*/ } return(Ok(context.SaveChanges())); //return new HttpResponseMessage(HttpStatusCode.OK).Headers.Location = }
// PUT: api/Departments/5 public IHttpActionResult Put(Department department) { if (ModelState.IsValid) { if (context.Locations.Contains(department.Location)) { var dbdepartment = context.Departments.Find(department.DepartmentId); if (dbdepartment != null) { Mapper.Map(department, dbdepartment); return(Ok(context.SaveChanges())); } return(NotFound()); } return(BadRequest("Locatia nu exista!")); } return(BadRequest()); }