//
        // GET: /CenterReferrals/Edit/
        public ActionResult Edit()
        {
            int centerId = account.GetCurrentUserCenterId();
            ReferralViewModelsEdit referralsEdit = new ReferralViewModelsEdit();
            List<CenterReferral> referralsList = repoService.centerReferralRepo.FindAllWithCenterId(centerId).ToList();
            List<ReferralViewModel> referralViewModelList = new List<ReferralViewModel>();

            foreach (var referral in referralsList)
            {
                ReferralViewModel r = new ReferralViewModel();
                r.referral = referral;
                r.count = 0;
                List<Referral> recordsOfReferralsMade = referral.Referrals.ToList();
                foreach (var record in recordsOfReferralsMade)
                {
                    r.totalNumberMade += record.CountReferred;
                }
                referralViewModelList.Add(r);
            }
            referralsEdit.Referrals = referralViewModelList;
            ViewBag.CurrentPage = "Referrals";
            return View(referralsEdit);
        }
 public ActionResult Edit(ReferralViewModelsEdit referralsEdit)
 {
     foreach (var item in referralsEdit.Referrals)
     {
         if (ModelState.IsValid)
         {
             if (item.count > 0)
             {
                 Referral r = new Referral();
                 r.CountReferred = item.count;
                 r.CenterReferralId = item.referral.Id;
                 repoService.centerReferralRepo.Insert(r);
             }
         }
     }
     return RedirectToAction("Index");
 }