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 ActionResult <PermissionOfRole> PostPermissionOfRole(PermissionOfRoleCM model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var checkExist = _permissionOfRoleService.CheckExist(model.PermissionID, model.RoleID);
                if (checkExist != null)
                {
                    return(BadRequest("Existed!"));
                }

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