Beispiel #1
0
        public IActionResult DeleteAuthority(int authorityId)
        {
            ErrorObject     response = new ErrorObject();
            ResponseMessage rm       = new ResponseMessage();

            if (string.IsNullOrEmpty(authorityId.ToString()) || authorityId == 0)
            {
                rm.Type    = AuthorityConstant.TypeAuthority;
                rm.Title   = AuthorityConstant.TitleDeleteAuthority;
                rm.Message = AuthorityConstant.MessageDeleteAuthority;
                rm.Status  = AuthorityConstant.statusError;
                var field = new { fieldErrors = rm.Title };


                return(StatusCode(400, Json(rm)));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            bool delete = _authorityRepository.DeleteAuthority(authorityId);

            if (delete)
            {
                object obj = new { message = AuthorityConstant.DeleteSuccess };
                return(StatusCode(200, obj));
            }
            else
            {
                response.entityName = AuthorityConstant.TypeAuthority;
                response.errorKey   = AuthorityConstant.MessageDeleteAuthority;
                response.title      = AuthorityConstant.TitleDeleteAuthority;
                response.status     = AuthorityConstant.statusError;
                response.message    = AuthorityConstant.MessageDeleteError;
                return(StatusCode(400, Json(response)));
            }
        }