Example #1
0
 public IHttpActionResult GetForm(int id)
 {
     if (id > 0)
     {
         ThrowIfUserHasNoRole(readRole);
     }
     using (ProjectEntryDataProvider projectEntryDataProvider = new ProjectEntryDataProvider(Db, ActiveUser, AccessControl, new ProjectQuery(Db)))
     {
         var data = projectEntryDataProvider.Get(id);
         SaveLog("Project", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id }));
         return(Ok(new SuccessResponse(data)));
     }
 }
        public SaveResult <ProjectEntryModel> Save(ProjectDTO projectDTO, DateTime dateStamp)
        {
            ModelValidationResult validationResult = projectValidator.Validate(projectDTO);
            bool success            = false;
            ProjectEntryModel model = null;

            if (validationResult.IsValid)
            {
                success = true;
                Update(projectDTO, dateStamp);
                Db.SaveChanges();
                model = projectEntryDataProvider.Get(projectDTO.Project_PK);
            }

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