Пример #1
0
        public IHttpActionResult PostLinkVtgStaffStudy(LinkVtgStaffStudyViewModel vtgStaffRole)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var vtgStaff = Mapper.Map <LinkVtgStaffStudyViewModel, LinkVtgStaffStudy>(vtgStaffRole);

            db.LinkVtgStaffStudies.Add(vtgStaff);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = vtgStaff.VtgStaffId }, vtgStaff));
        }
Пример #2
0
        public IHttpActionResult PutStudyRoles(int id, LinkVtgStaffStudyViewModel vtgStaffRoleVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != vtgStaffRoleVM.VtgStaffStudyLinkId)
            {
                return(BadRequest());
            }

            var vtgStaffRole = Mapper.Map <LinkVtgStaffStudyViewModel, LinkVtgStaffStudy>(vtgStaffRoleVM);

            db.Entry(vtgStaffRole).State = EntityState.Modified;
            db.SaveChanges();
            return(StatusCode(HttpStatusCode.NoContent));
        }