public virtual IGenericWebApiResult Delete(params object[] keyValues) { try { using (var result = new GenericWebApiResult <T>()) { result.Success = repo.Delete(keyValues); result.Message = result.Success ? BaseConstants.MESSAGE_DELETE_SUCCESS : BaseConstants.MESSAGE_INVALID_DATA; return(result); } } catch (Exception ex) { using (var result = new GenericWebApiResult <T>(ex)) { result.Success = false; dynamic more = new ExpandoObject(); more.Errors = ex.Message; result.More = more; return(result); } } }
/// <summary> /// Save a new payment or update an existin one. /// </summary> /// <param name="paymentVm">item to save</param> public void Save(PaymentViewModel paymentVm) { paymentVm.IsCleared = paymentVm.ClearPaymentNow; //delete recurring payment if isRecurring is no longer set. if (paymentVm.IsRecurring) { recurringDataAccess.Delete(paymentVm.RecurringPayment); paymentVm.RecurringPayment.Id = 0; } if (paymentVm.Id == 0) { data.Add(paymentVm); dataAccess.Add(paymentVm.GetPayment()); } else { dataAccess.Update(paymentVm.GetPayment()); } }
/// <summary> /// Deletes the passed payment and removes the item from cache /// </summary> /// <param name="paymentVmToDelete">Payment to delete.</param> public void Delete(PaymentViewModel paymentVmToDelete) { var payments = Data.Where(x => x.Id == paymentVmToDelete.Id).ToList(); foreach (var payment in payments) { data.Remove(payment); dataAccess.Delete(paymentVmToDelete.GetPayment()); // If this accountToDelete was the last finacial accountToDelete for the linked recurring accountToDelete // delete the db entry for the recurring accountToDelete. DeleteRecurringPaymentIfLastAssociated(payment); } }
/// <summary> /// Deletes the passed category and removes it from cache /// </summary> /// <param name="categoryToDelete">accountToDelete to delete</param> public void Delete(Category categoryToDelete) { data.Remove(categoryToDelete); dataAccess.Delete(categoryToDelete); }
/// <summary> /// Deletes the passed account and removes it from cache /// </summary> /// <param name="accountToDelete">accountToDelete to delete</param> public void Delete(Account accountToDelete) { data.Remove(accountToDelete); dataAccess.Delete(accountToDelete); }