public SaveResult <AreaEntryModel> Save(AreaDTO areaDTO, DateTime dateStamp) { ModelValidationResult validationResult = areaValidator.Validate(areaDTO); bool success = false; AreaEntryModel model = null; if (!validationResult.IsValid) { return(new SaveResult <AreaEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.", Model = model, ValidationResult = validationResult }); } tblM_Area area = AddArea(areaDTO, dateStamp); Db.SaveChanges(); success = true; model = areaEntryDataProvider.Get(area.Area_PK); return(new SaveResult <AreaEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully created." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }
public IHttpActionResult GetForm(int id) { if (id > 0) { ThrowIfUserHasNoRole(readRole); } using (AreaEntryDataProvider areaEntryDataProvider = new AreaEntryDataProvider(Db, ActiveUser, AccessControl, new AreaQuery(Db))) { var data = areaEntryDataProvider.Get(id); SaveLog("Area", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id })); return(Ok(new SuccessResponse(data))); } }