public IEnumerable <VmPaymentRule> GetPaymentRulesByFilter(VmPaymentRule filterItem) { var paymentRuleRepository = UnitOfWork.GetRepository <PaymentRuleRepository>(); var viewFilterItem = new PaymentRule { Id = filterItem.Id, TypeOfRegistration = filterItem.TypeOfRegistration, FirstTeamFee = filterItem.FirstTeamFee, ExtraTeamDiscount = filterItem.ExtraTeamDiscount, DueDate = DateTime.Parse(filterItem.DueDate ?? "1/1/0001"), DueDatePrefix = filterItem.DueDatePrefix, }; var paymentRuleList = paymentRuleRepository.Select(viewFilterItem, 0, int.MaxValue); var vmPaymentRuleList = from paymentRule in paymentRuleList select new VmPaymentRule { Id = paymentRule.Id, TypeOfRegistration = paymentRule.TypeOfRegistration, FirstTeamFee = paymentRule.FirstTeamFee, ExtraTeamDiscount = paymentRule.ExtraTeamDiscount, DueDate = paymentRule.DueDate.ToString(), DueDatePrefix = paymentRule.DueDatePrefix, }; return(vmPaymentRuleList); }
public int CreatePaymentRule(VmPaymentRule vmPaymentRule) { var result = -1; try { var paymentRuleRepository = UnitOfWork.GetRepository <PaymentRuleRepository>(); var newPaymentRule = new PaymentRule { Id = vmPaymentRule.Id, TypeOfRegistration = vmPaymentRule.TypeOfRegistration, FirstTeamFee = vmPaymentRule.FirstTeamFee, ExtraTeamDiscount = vmPaymentRule.ExtraTeamDiscount, DueDate = DateTime.Parse(vmPaymentRule.DueDate), DueDatePrefix = vmPaymentRule.DueDatePrefix, }; paymentRuleRepository.CreatePaymentRule(newPaymentRule); UnitOfWork.Commit(); result = newPaymentRule.Id; } catch (Exception ex) { result = -1; } return(result); }
public ActionResult CreatePaymentRule(VmPaymentRule model) { var result = -1; var blPaymentRule = new BLPaymentRule(); result = blPaymentRule.CreatePaymentRule(model); var message = ""; if (result == -1) { message = "Operation has been failed...\n call system Admin"; } else { message = "Operation has been succeeded"; } var jsonData = new { paymentRuleId = model.Id, success = result, message }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public JsonResult GetTeamMembersByFilter(VmPaymentRule filterItem = null) { var blPaymwntRule = new BLPaymentRule(); var paymentRuleList = blPaymwntRule.GetPaymentRulesByFilter(filterItem); return(Json(paymentRuleList, JsonRequestBehavior.AllowGet)); }
public VmPaymentRule GetPaymentRuleBySuitableDueDate(DateTime dueDate) { var paymentRuleRepository = UnitOfWork.GetRepository <PaymentRuleRepository>(); PaymentRule paymentRule = paymentRuleRepository.GetPaymentRuleByDueDate(dueDate); if (paymentRule == null) { var paymentRuleList = paymentRuleRepository.GetPaymentRuleBySuitableDueDate(); var maxDueDate = paymentRuleList.Max(i => i.DueDate); if (dueDate > maxDueDate) { return(null); } var minDueDate = paymentRuleList.Min(i => i.DueDate); if (dueDate <= minDueDate) { return((from s in paymentRuleList where s.DueDate == minDueDate select new VmPaymentRule { Id = s.Id, TypeOfRegistration = s.TypeOfRegistration, FirstTeamFee = s.FirstTeamFee, ExtraTeamDiscount = s.ExtraTeamDiscount, DueDate = s.DueDate.ToString(), DueDatePrefix = s.DueDatePrefix, }).FirstOrDefault()); } else { paymentRule = BinarySearchRecursive(paymentRuleList, dueDate, 0, paymentRuleList.Count - 1); } } VmPaymentRule vmPaymentRule = null; if (paymentRule != null) { vmPaymentRule = new VmPaymentRule { Id = paymentRule.Id, TypeOfRegistration = paymentRule.TypeOfRegistration, FirstTeamFee = paymentRule.FirstTeamFee, ExtraTeamDiscount = paymentRule.ExtraTeamDiscount, DueDate = paymentRule.DueDate.ToString(), DueDatePrefix = paymentRule.DueDatePrefix, }; } return(vmPaymentRule); }
public VmPaymentRule GetPaymentRuleById(int id) { var paymentRuleRepository = UnitOfWork.GetRepository <PaymentRuleRepository>(); var paymentRule = paymentRuleRepository.GetPaymentRuleById(id); var vmPaymentRule = new VmPaymentRule { Id = paymentRule.Id, TypeOfRegistration = paymentRule.TypeOfRegistration, FirstTeamFee = paymentRule.FirstTeamFee, ExtraTeamDiscount = paymentRule.ExtraTeamDiscount, DueDate = paymentRule.DueDate.ToString(), DueDatePrefix = paymentRule.DueDatePrefix, }; return(vmPaymentRule); }
public bool UpdatePaymentRule(VmPaymentRule vmPaymentRule) { var PaymentRuleRepository = UnitOfWork.GetRepository <PaymentRuleRepository>(); var updateablePaymentRule = new PaymentRule { Id = vmPaymentRule.Id, TypeOfRegistration = vmPaymentRule.TypeOfRegistration, FirstTeamFee = vmPaymentRule.FirstTeamFee, ExtraTeamDiscount = vmPaymentRule.ExtraTeamDiscount, DueDate = DateTime.Parse(vmPaymentRule.DueDate), DueDatePrefix = vmPaymentRule.DueDatePrefix, }; PaymentRuleRepository.UpdatePaymentRule(updateablePaymentRule); return(UnitOfWork.Commit()); }
public ActionResult UpdatePaymentRule(VmPaymentRule model) { var message = ""; try { if (!ModelState.IsValid) { var jsonEx = JsonConvert.SerializeObject(ModelState, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Serialize }); var jsonException = new { paymentRuleId = model.Id, success = false, message = message + "\n" + jsonEx }; return(Json(jsonException, JsonRequestBehavior.AllowGet)); } var result = true; var blPaymentRule = new BLPaymentRule(); result = blPaymentRule.UpdatePaymentRule(model); if (result == false) { message += "Operation has been failed...\n call system Admin\n"; } else { message += "Operation has been succeeded"; } var jsonData = new { paymentRuleId = model.Id, success = result, message }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var jsonEx = JsonConvert.SerializeObject(ex, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var jsonException = new { paymentRuleId = model.Id, success = false, message = message + "\n" + jsonEx }; return(Json(jsonException, JsonRequestBehavior.AllowGet)); } }