public ActionResult Create(PaymentRule paymentrule, int id=0, bool isCurrent=false)
 {
     if (ModelState.IsValid)
     {
         paymentrule.CreatedDate = DateTime.Today;
         paymentrule.PaymentProfileId = id;
         if (isCurrent)
         {
             paymentrule.EffectiveDate = DateTime.Today;
         }
         db.PaymentRules.Add(paymentrule);
         db.SaveChanges();
         return Content(Boolean.TrueString);
     }
     return Content("Please review your form");
 }
 public ActionResult Edit(PaymentRule paymentrule, int[] ruleStudents, int[] ruleAmount, bool? Variable)
 {
     if (ModelState.IsValid)
     {
         if (Variable??false)
         {
             var xelement = new XElement("Root");
             for (int i = 0; i < ruleStudents.Length; i++)
             {
                 if (ruleStudents[i] > 0)
                 {
                     xelement.Add(new XElement("Rule", new XAttribute("NoOfStudents", ruleStudents[i]), new XAttribute("Amount", ruleAmount[i])));
                 }
             }
             paymentrule.xRule = xelement;
             paymentrule.Amount = 0;
             paymentrule.Variable = true;
         }
         else
         {
             paymentrule.CreatedDate = DateTime.Today;
             paymentrule.Variable = false;
         }
         db.Entry(paymentrule).State = EntityState.Modified;
         db.SaveChanges();
         return Content(Boolean.TrueString);
     }
     else
     {
         return Content("Please review your form");
     }
 }
 public ActionResult EditPartial(PaymentRule paymentrule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(paymentrule).State = EntityState.Modified;
         db.SaveChanges();
         return Content(Boolean.TrueString);
     }
     else
     {
         return Content("Please review your form");
     }
 }
 public PaymentProfileEditViewModel()
 {
     OldPaymentRules = new List<PaymentRule>();
     FuturePaymentRule = new PaymentRule();
     CurrentPaymentRule = new PaymentRule();
 }