public IHttpActionResult GetForm(int id)
        {
            string accessType = "MappingRoleToRoleGroup_ViewAll";

            ThrowIfUserCannotAccess(accessType);
            using (MappingRoleToRoleGroupEntryDataProvider mappingRoleToRoleGroupEntryDataProvider = new MappingRoleToRoleGroupEntryDataProvider(Db, ActiveUser, AccessControl, new MappingRoleToRoleGroupQuery(Db)))
            {
                var data = mappingRoleToRoleGroupEntryDataProvider.Get(id);
                SaveLog("MappingRoleToRoleGroup", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
                return(Ok(new SuccessResponse(data)));
            }
        }
예제 #2
0
 public IHttpActionResult GetForm(int id)
 {
     if (id > 0)
     {
         ThrowIfUserHasNoRole(readRole);
     }
     using (MappingRoleToRoleGroupEntryDataProvider mappingRoleToRoleGroupEntryDataProvider = new MappingRoleToRoleGroupEntryDataProvider(Db, ActiveUser, AccessControl, new MappingRoleToRoleGroupQuery(Db)))
     {
         var data = mappingRoleToRoleGroupEntryDataProvider.Get(id);
         SaveLog("MappingRoleToRoleGroup", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
예제 #3
0
        public SaveResult <MappingRoleToRoleGroupEntryModel> Save(MappingRoleToRoleGroupDTO mappingRoleToRoleGroupDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = mappingRoleToRoleGroupValidator.Validate(mappingRoleToRoleGroupDTO);
            bool success = false;
            MappingRoleToRoleGroupEntryModel model = null;

            if (validationResult.IsValid)
            {
                success = true;
                Update(mappingRoleToRoleGroupDTO, dateStamp);
                Db.SaveChanges();
                model = mappingRoleToRoleGroupEntryDataProvider.Get(mappingRoleToRoleGroupDTO.RoleGroup_PK.Value);
            }

            return(new SaveResult <MappingRoleToRoleGroupEntryModel>
            {
                Success = success,
                Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.",
                Model = model,
                ValidationResult = validationResult
            });
        }
        public SaveResult <MappingRoleToRoleGroupEntryModel> Save(RoleMapping roleMapping, DateTime dateStamp)
        {
            ModelValidationResult validationResult = mappingRoleToRoleGroupValidator.ValidateRoleMapping(roleMapping);
            bool success = false;
            MappingRoleToRoleGroupEntryModel model = null;

            if (validationResult.IsValid)
            {
                Insert(roleMapping, dateStamp);
                Db.SaveChanges();

                success = true;
                model   = mappingRoleToRoleGroupEntryDataProvider.Get(roleMapping.RoleGroup_PK);
            }

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