public IHttpActionResult GetForm(int id) { if (id > 0) { ThrowIfUserHasNoRole(readRole); } using (CabangEntryDataProvider cabangEntryDataProvider = new CabangEntryDataProvider(Db, ActiveUser, AccessControl, new CabangQuery(Db))) { var data = cabangEntryDataProvider.Get(id); SaveLog("Cabang", "GetForm", JsonConvert.SerializeObject(new { primaryKey = id })); return(Ok(new SuccessResponse(data))); } }
public SaveResult <CabangEntryModel> Save(CabangDTO cabangDTO, DateTime dateStamp) { ModelValidationResult validationResult = cabangValidator.Validate(cabangDTO); bool success = false; CabangEntryModel model = null; if (validationResult.IsValid) { success = true; Update(cabangDTO, dateStamp); Db.SaveChanges(); model = cabangEntryDataProvider.Get(cabangDTO.Cabang_PK); } return(new SaveResult <CabangEntryModel> { Success = success, Message = validationResult.IsValid ? "Data successfully updated." : "Validation error occured.", Model = model, ValidationResult = validationResult }); }