Exemplo n.º 1
0
        public ActionResult PostUserGroup(UserGroupCM model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var checkExist = _userGroupService.CheckExist(model.UserId, model.GroupID);
                if (checkExist != null)
                {
                    return(BadRequest("Existed!"));
                }

                UserGroup userGroup = new UserGroup();
                userGroup = _mapper.Map <UserGroup>(model);
                _userGroupService.Create(userGroup);
                return(StatusCode(201, userGroup.ID));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }