public IHttpActionResult GetForm(int id) { if (id > 0) { ThrowIfUserHasNoRole(readRole); } using (KotaEntryDataProvider kotaEntryDataProvider = new KotaEntryDataProvider(Db, ActiveUser, AccessControl, new KotaQuery(Db))) { var data = kotaEntryDataProvider.Get(id); SaveLog("Kota", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id })); return(Ok(new SuccessResponse(data))); } }
public SaveResult <KotaEntryModel> Save(KotaDTO kotaDTO, DateTime dateStamp) { ModelValidationResult validationResult = kotaValidator.Validate(kotaDTO); bool success = false; KotaEntryModel model = null; if (validationResult.IsValid) { success = true; Update(kotaDTO, dateStamp); Db.SaveChanges(); model = kotaEntryDataProvider.Get(kotaDTO.Kota_PK); } return(new SaveResult <KotaEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }