public int Edit(PaymentMethod paymentMethod) { int editIndex = 0; try { PaymentMethod _paymentMethod = GetPaymentbyId(paymentMethod.PaymentMethodId); _paymentMethod.PatientId = paymentMethod.PatientId; _paymentMethod.PaymentMethodId = paymentMethod.PaymentMethodId; _paymentMethod.ServiceId = paymentMethod.ServiceId; _paymentMethod.Date = paymentMethod.Date; _paymentMethod.Charge = paymentMethod.Charge; _paymentMethod.DiscountAmount = paymentMethod.DiscountAmount; _paymentMethod.Paid += paymentMethod.Paid; _paymentMethod.TotalCharge = paymentMethod.Charge - paymentMethod.DiscountAmount; _paymentMethod.Due = _paymentMethod.TotalCharge - _paymentMethod.Paid; _paymentMethod.PaymentType = paymentMethod.PaymentType; _paymentMethod.LastPaidDate = DateTime.Now; editIndex = _paymentMethodRepository.Edit(_paymentMethod); } catch (Exception exception) { throw new Exception(exception.Message); } return(editIndex); }