示例#1
0
        public ActionResult EditReferralModal(int referralId, ReferralVo referral)
        {
            ReferralVo item            = referralManager.get(referralId);
            decimal?   oldFinalPayment = item.finalQuote;

            if (this.ModelState.IsValid)
            {
                if (item.referralId > 0)
                {
                    item.description        = referral.description;
                    item.quote              = referral.quote;
                    item.referralDate       = referral.referralDate;
                    item.accepted           = referral.accepted;
                    item.finalQuote         = referral.finalQuote;
                    item.finishDate         = referral.finishDate;
                    item.commissionAmount   = referral.commissionAmount;
                    item.commissionDatePaid = referral.commissionDatePaid;
                    ReferralVo     r          = referralManager.update(item, referralId);
                    int            orgID      = OrganizationManager.getOrgIDForClient(item.clientId);
                    OrganizationVo currentOrg = orgManager.get(orgID);
                    if (currentOrg != null)
                    {
                        OrganizationManager.addAllFinalPaymentsForMembertoOrganizationFeeAmount(currentOrg, item.finalQuote, oldFinalPayment);
                    }
                    //notificationManager.sendReferralNotification(new int[] { referralId }, true);
                    return(View("CloseModalsAndRefresh"));
                }
            }
            return(PartialView("_EditReferralModal", referral));
        }
示例#2
0
        // Direct edit of given referral
        public ActionResult EditReferralModal(int referralId)
        {
            ViewBag.ModalDialogTitle = "Edit referral";
            ReferralVo referral = referralManager.get(referralId);

            return(PartialView("_EditReferralModal", referral));
        }
        public ReferralVo update(ReferralVo input, int?referralId = null)
        {
            using (var db = new MainDb())
            {
                if (referralId == null)
                {
                    referralId = input.referralId;
                }

                var res = db.referrals.FirstOrDefault(e => e.referralId == referralId);

                if (res == null)
                {
                    return(null);
                }

                input.created = res.created;
                // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);


                db.SaveChanges();
                return(res);
            }
        }
示例#4
0
        public ActionResult Edit(int id, ReferralVo input)
        {
            if (this.ModelState.IsValid)
            {
                var res = referralManager.update(input, id);
                return(RedirectToAction("Index"));
            }

            return(View(input));
        }
示例#5
0
        public void addTrippleReferralTest()
        {
            ReferralVo rf = new ReferralVo();

            rf.referralDate          = DateTime.Now;
            rf.companyCategoryTypeId = 5; // caterers     1; // dentists
            int x = referralRecordeManager.addTrippleReferral(34, rf).Count();

            Assert.IsTrue(true);
        }
示例#6
0
        public ActionResult TripleReferral(int id, int companyCategoryTypeId)
        {
            ViewBag.ModalDialogTitle = "Add triple referral";
            // id => clientId
            ReferralVo newRefFilter = new ReferralVo();

            newRefFilter.referralDate = DateTime.Now;
            newRefFilter.clientId     = id;
            return(PartialView("_EditReferralModal", newRefFilter));
        }
        public ReferralVo insert(ReferralVo input)
        {
            using (var db = new MainDb())
            {
                db.referrals.Add(input);
                db.SaveChanges();

                return(input);
            }
        }
示例#8
0
        public ActionResult Create(ReferralVo input)
        {
            if (this.ModelState.IsValid)
            {
                var item = referralManager.insert(input);
                return(RedirectToAction("Index"));
            }


            return(View(input));
        }
示例#9
0
 public ActionResult AddSingleReferral(ReferralVo referral, int companyCategoryTypeId)
 {
     if (this.ModelState.IsValid)
     {
         referral.companyCategoryTypeId = companyCategoryTypeId;
         ReferralVo r = referralManager.insert(referral);
         notificationManager.sendReferralNotification(new int[] { referral.referralId });
         return(View("CloseModalsAndRefresh"));
     }
     return(PartialView("_EditReferralModal", referral));
 }
示例#10
0
 public ActionResult TripleReferral(int id, int companyCategoryTypeId, ReferralVo referral)
 {
     if (this.ModelState.IsValid)
     {
         // id => clientId
         referral.companyCategoryTypeId = companyCategoryTypeId;
         var referrals = referralRecordManager.addTrippleReferral(id, referral, true);
         notificationManager.sendReferralNotification(referrals);
         return(View("CloseModalsAndRefresh"));
     }
     return(PartialView("_EditReferralModal", referral));
 }
示例#11
0
        public ActionResult AddSingleReferral(int id, int coId, int companyCategoryTypeId, int dlgType)
        {
            ViewBag.ModalDialogTitle = "Add a referral";
            // id => clientId
            ReferralVo newRef = new ReferralVo();

            newRef.referralDate          = DateTime.Now;
            newRef.clientId              = id;
            newRef.companyId             = coId;
            newRef.companyCategoryTypeId = companyCategoryTypeId;
            newRef.dlgType = dlgType;
            return(PartialView("_EditReferralModal", newRef));
        }
 public void addNewOrUpdateReferral(ReferralVo newReferral)
 {
     using (var db = new MainDb())
     {
         if (newReferral.referralId == 0) // add new
         {
             var res = db.referrals.Add(newReferral);
             db.SaveChanges();
         }
         else // update existing .... TODO: use this or remove the else block and rename the function
         {
             return;
         }
     }
 }
        /// <summary>
        ///  Caterers, iPayment, 01/30/2014
        ///  Caterers, iPayment Inc, 01/30/2014
        ///  Caterers, Jerry's, 01/30/2014
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="referralFilter"></param>
        /// <param name="isActive"></param>
        /// <returns></returns>
        public IEnumerable <int> addTrippleReferral(int clientId, ReferralVo referralFilter, bool?isActive = true)
        {
            List <int> referrals = new List <int>();

            using (var db = new MainDb())
            {
                var result =
                    (from c in db.companies
                     join ccl in db.companyCategoryLookups on c.companyId equals ccl.companyId
                     where ccl.companyCategoryTypeId == referralFilter.companyCategoryTypeId
                     select new { Company = c, Count = c.referralses.Any() ? c.referralses.Count() : 0 })
                    .OrderBy(c => c.Count)
                    .Take(3)
                    .Select(c => new { c.Company.companyId, c.Count })
                    .ToList();

                foreach (var rfData in result)
                {
                    ReferralVo rf = new ReferralVo();
                    rf.referralId            = 0; //referralId is 0 because we are creating new ones
                    rf.clientId              = clientId;
                    rf.companyId             = rfData.companyId;
                    rf.companyCategoryTypeId = referralFilter.companyCategoryTypeId; // or rfData.companyCategoryTypeId
                    rf.referralDate          = referralFilter.referralDate;
                    rf.quote       = referralFilter.quote;
                    rf.accepted    = referralFilter.accepted;
                    rf.finalQuote  = referralFilter.finalQuote;
                    rf.finishDate  = referralFilter.finishDate;
                    rf.description = referralFilter.description;
                    addNewOrUpdateReferral(rf);

                    referrals.Add(rf.referralId);
                }

                return(referrals);
            }
        }
示例#14
0
        public ActionResult Create()
        {
            var vo = new ReferralVo();

            return(View(vo));
        }