예제 #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));
            }
        }
예제 #3
0
 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}"));
     }
 }