コード例 #1
0
        public HttpResponseMessage PostDept(UserInDeptRoleCreateViewModel model)
        {
            if (model == null)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
            UserInDeptRole item = Mapper.Map <UserInDeptRoleCreateViewModel, UserInDeptRole>(model);


            _userInDeptRolesService.Add(item);
            _db.SaveChanges();
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
コード例 #2
0
        public IHttpActionResult AddToPost(UserInDeptRoleShortViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userInDeptRole = _userInDeptRolesService.GetAll().FirstOrDefault(x => x.DepartmentDeptRoleId == model.DeptId);

            _userInDeptRolesService.Delete(userInDeptRole, true);
            _db.SaveChanges();

            UserInDeptRole item = Mapper.Map <UserInDeptRoleShortViewModel, UserInDeptRole>(model);

            _userInDeptRolesService.Add(item);
            _db.SaveChanges();
            return(Ok());
        }