コード例 #1
0
 public ActionResult <ActionType> PostActionType(ActionTypeCM model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         ActionType actionType = new ActionType();
         actionType = _mapper.Map <ActionType>(model);
         _actionTypeService.Create(actionType);
         _actionTypeService.Save();
         return(StatusCode(201, "Action Type Created!"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #2
0
        public ActionResult <ActionType> PostActionType(ActionTypeCM model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var nameExist = _actionTypeService.GetByName(model.Name);
                if (nameExist != null)
                {
                    return(BadRequest("ActionType Name is existed!"));
                }

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