/// <summary> /// Soft Supprime Un Recue /// </summary> /// <param name="myPayOff">Guid du Ticket</param> /// <returns>True pour Success</returns> protected internal static bool DeleteFeeReceipt(BillPayOff myPayOff) { using (var db = new EconomatContext()) { //db.FeeReceipts.Attach(myReceipt); db.Entry(myPayOff).State = EntityState.Modified; return(db.SaveChanges() > 0); } }
/// <summary> /// Modifier un Recue /// </summary> /// <param name="myPayOff"></param> /// <returns>True pour Success</returns> protected internal static bool UpdateFeeReceipt(BillPayOff myPayOff) { //myPayement.DateEdited = DateTime.Now; using (var db = new EconomatContext()) { //db.FeeReceipts.Attach(myReceipt); db.Entry(myPayOff).State = EntityState.Modified; return(db.SaveChanges() > 0); } }
/// <summary> /// Payer Frais d'Etude /// </summary> /// <param name="myPayOff"></param> /// <exception cref="InvalidDataException">CAN_NOT_FIND_SCHOOL_FEE_REFERENCE</exception> /// <exception cref="InvalidOperationException">SCHOOL_FEE_ALREADY_PAID</exception> /// <returns>True pour Success</returns> public bool PaySchoolFee(BillPayOff myPayOff) { using (var db = new EconomatContext()) { var newSchoolFee = db.SchoolFees.Find(myPayOff.SchoolFeeGuid); if (newSchoolFee == null) { throw new InvalidOperationException("CAN_NOT_FIND_BILL_REFERENCE"); } if (newSchoolFee.IsPaid) { throw new InvalidOperationException("BILL_ALREADY_PAID"); } if (string.IsNullOrEmpty(newSchoolFee.NumeroReference)) { newSchoolFee.NumeroReference = GetNewReceipRef(); } if (RefRecueExist(newSchoolFee.NumeroReference)) { throw new InvalidOperationException("RECEIPT_REFERENCE_ALREADY_EXIST"); } if (string.IsNullOrEmpty(newSchoolFee.Description)) { newSchoolFee.Description = "Reglement effectuer le " + DateTime.Now; } newSchoolFee.IsPaid = true; newSchoolFee.IsPaidBy = myPayOff.IsPaidBy; newSchoolFee.PaymentMethode = myPayOff.PaymentMethode; newSchoolFee.NumeroReference = myPayOff.NumeroReference; newSchoolFee.NumeroVirement = myPayOff.NumeroVirement; newSchoolFee.Bank = myPayOff.Bank; newSchoolFee.Description = myPayOff.Description; newSchoolFee.LastEditDate = DateTime.Now; newSchoolFee.DatePaid = DateTime.Now; db.SchoolFees.Attach(newSchoolFee); db.Entry(newSchoolFee).State = EntityState.Modified; return(db.SaveChanges() > 0); } }