예제 #1
0
        // 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());
        }
예제 #2
0
 // 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();
     
 }
예제 #3
0
        // 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());
        }
예제 #4
0
        // 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());
        }
예제 #5
0
        // 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());
        }
예제 #6
0
        // 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());
        }
예제 #7
0
        // 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 =
        }
예제 #8
0
        // 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());
        }