コード例 #1
0
        public async Task <IActionResult> CreateDepartment(AddDepartmentDto model)
        {
            try
            {
                var department = _mapper.Map <Departments>(model);
                if (!await _manager.CreateDepartment(department))
                {
                    return(Ok(new JsonMessageResult("创建失败!", 0, null)));
                }

                return(CreatedAtAction(nameof(GetDepartment), new { department.Id }, department));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Ok(new JsonMessageResult(e.Message, 0, null)));
            }
        }
コード例 #2
0
 /// <summary>
 /// Posts the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public int Post([FromBody] Department_vm value)
 {
     _logger.Info("Adding a new Department.");
     return(_nsDepartmentManager.CreateDepartment(value));
 }