public ActionResult <PermissionOfRole> PostPermissionOfRole(PermissionOfRoleCM model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         PermissionOfRole permissionOfRole = new PermissionOfRole();
         permissionOfRole = _mapper.Map <PermissionOfRole>(model);
         _permissionOfRoleService.Create(permissionOfRole);
         _permissionOfRoleService.Save();
         return(StatusCode(201, "Permission Of Role is created!"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 2
0
 public IActionResult PutPermissionOfRole(PermissionOfRoleUM model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         var permissionOfRoleInDb = _permissionOfRoleService.GetByID(model.ID);
         if (permissionOfRoleInDb == null)
         {
             return(BadRequest("ID not found!"));
         }
         _mapper.Map(model, permissionOfRoleInDb);
         _permissionOfRoleService.Save();
         return(Ok("success"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }