示例#1
0
 public async Task <IActionResult> Create([Bind("Id,Name,Description")] Role role)
 {
     if (ModelState.IsValid)
     {
         _db.Create(role);
         _db.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(role));
 }
示例#2
0
        public IActionResult Create([FromBody] RoleDTO roleDto)
        {
            var role = _mapper.Map <Role>(roleDto);

            try
            {
                Role newRole = _roleService.Create(role);
                return(Ok(newRole.Id));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
 public IActionResult Create([FromBody] RoleEntity model)
 {
     try
     {
         if (model != null)
         {
             _role.Create(model);
         }
         return(Json(model));
     }
     catch (Exception ex)
     {
         _logger.LogCritical($"Exception while get list of items.", ex);
         return(StatusCode(500, $"Exception while get list of items. {ex.Message}"));
     }
 }