public static DisbursementVcrStatu ChangeStatus(LoanDisbursementVcr loanDisbursementVoucher, DisbursementVcrStatusType statusType, DateTime today) { DisbursementVcrStatu disbursementStatus = GetActive(loanDisbursementVoucher); if (CanChangeStatus(disbursementStatus.DisbursementVcrStatusType, statusType, today)) return CreateOrUpdateCurrent(loanDisbursementVoucher, statusType, today); return disbursementStatus; }
public static bool CanChangeStatus(DisbursementVcrStatusType statusFrom, DisbursementVcrStatusType statusTo, DateTime today) { //check if change status is allowed through the DisbursementVcrStatusTypeAssoc var checkStatus = Context.DisbursementVcrStatTypeAssocs.SingleOrDefault(entity => entity.FromStatusTypeId == statusFrom.Id && entity.ToStatusTypeId == statusTo.Id && entity.EndDate == null); if (checkStatus != null) return true; else return false; }
public static DisbursementVcrStatu Create(LoanDisbursementVcr loanDisbursementVoucher, DisbursementVcrStatusType statusType, DateTime today) { DisbursementVcrStatu status = new DisbursementVcrStatu(); status.DisbursementVoucherStatTypId = statusType.Id; status.LoanDisbursementVcr = loanDisbursementVoucher; status.Remarks = null; status.TransitionDateTime = today; status.IsActive = true; Context.DisbursementVcrStatus.AddObject(status); return status; }
public static DisbursementVcrStatu CreateOrUpdateCurrent(LoanDisbursementVcr loanDisbursementVoucher, DisbursementVcrStatusType statusType, DateTime today) { DisbursementVcrStatu disbursementStatus = GetActive(loanDisbursementVoucher); if (disbursementStatus != null && disbursementStatus.DisbursementVcrStatusType.Id != statusType.Id) disbursementStatus.IsActive = false; if (disbursementStatus == null || disbursementStatus.DisbursementVcrStatusType.Id != statusType.Id) { DisbursementVcrStatu newDisbursementStatus = new DisbursementVcrStatu(); newDisbursementStatus.DisbursementVoucherStatTypId = statusType.Id; newDisbursementStatus.LoanDisbursementVcr = loanDisbursementVoucher; newDisbursementStatus.Remarks = null; newDisbursementStatus.TransitionDateTime = today; newDisbursementStatus.IsActive = true; Context.DisbursementVcrStatus.AddObject(newDisbursementStatus); return newDisbursementStatus; } return disbursementStatus; }
public static DisbursementVcrStatu RetrieveStatus(LoanDisbursementVcr loanDisbursementVoucher, DisbursementVcrStatusType statusType) { return Context.DisbursementVcrStatus.SingleOrDefault(entity => entity.LoanDisbursementVoucherId == loanDisbursementVoucher.Id && entity.TransitionDateTime == GetActive(loanDisbursementVoucher).TransitionDateTime && entity.DisbursementVoucherStatTypId == statusType.Id); }
private DisbursementVcrStatu CreateVoucherStatusWithType(LoanDisbursementVcr voucher, DateTime today, DisbursementVcrStatusType type) { DisbursementVcrStatu voucherStatus = new DisbursementVcrStatu(); voucherStatus.DisbursementVcrStatusType = type; voucherStatus.IsActive = true; voucherStatus.LoanDisbursementVcr = voucher; voucherStatus.TransitionDateTime = today; Context.DisbursementVcrStatus.AddObject(voucherStatus); return voucherStatus; }