Пример #1
0
        public IHttpActionResult GetForm(int id)
        {
            string accessType = "Role_ViewAll";

            ThrowIfUserCannotAccess(accessType);
            using (RoleEntryDataProvider roleEntryDataProvider = new RoleEntryDataProvider(Db, ActiveUser, AccessControl, new RoleQuery(Db)))
            {
                var data = roleEntryDataProvider.Get(id);
                SaveLog("Role", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
                return(Ok(new SuccessResponse(data)));
            }
        }
Пример #2
0
 public IHttpActionResult GetForm(int id)
 {
     if (id > 0)
     {
         ThrowIfUserHasNoRole(readRole);
     }
     using (RoleEntryDataProvider roleEntryDataProvider = new RoleEntryDataProvider(Db, ActiveUser, AccessControl, new RoleQuery(Db)))
     {
         var data = roleEntryDataProvider.Get(id);
         SaveLog("Role", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
        public SaveResult <RoleEntryModel> Save(RoleDTO roleDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = roleValidator.Validate(roleDTO);
            bool           success = false;
            RoleEntryModel model   = null;

            if (validationResult.IsValid)
            {
                success = true;
                Update(roleDTO, dateStamp);
                Db.SaveChanges();
                model = roleEntryDataProvider.Get(roleDTO.Role_PK);
            }

            return(new SaveResult <RoleEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }