Example #1
0
        public ActionResult Suppress(int LeadId)
        {
            //Get Lead, Cards for Lead, Appointments for Lead, Accounts for Lead
            var leadSuppress        = GetLeadByLeadId(LeadId);
            var cardsforlead        = _CardRepository.GetCardByLeadId(LeadId);
            var appointmentsforlead = _AppointmentRepository.GetAppointmentByLeadId(LeadId);
            var accountsforlead     = _AccountRepository.GetAccountsByLeadId(LeadId);

            //Delete all of them
            foreach (var card in cardsforlead)
            {
                _CardRepository.DeleteCard(card);
            }
            foreach (var appointment in appointmentsforlead)
            {
                _AppointmentRepository.DeleteAppointmentSheet(appointment);
            }
            foreach (var account in accountsforlead)
            {
                _AccountRepository.DeleteAccounts(account);
            }

            //leadSuppress.Suppressed = true;
            //We are deleting the lead here after deleting all the cards, accounts and appointmentsheets for him
            DeleteLead(leadSuppress);
            return(RedirectToAction("Index"));
        }
        public ActionResult Suppress(string id)
        {
            Web.ViewModel.ImportLeadViewModel il = new Web.ViewModel.ImportLeadViewModel();

            string[] ids = id.Split(',');
            // IList<Lead> leads;
            foreach (string leadid in ids)
            {
                int lid = int.Parse(leadid);

                var leadSuppress        = GetLeadByLeadId(lid);
                var cardsforlead        = _CardRepository.GetCardByLeadId(lid);
                var appointmentsforlead = _AppointmentRepository.GetAppointmentByLeadId(lid);
                var accountsforlead     = _AccountRepository.GetAccountsByLeadId(lid);
                foreach (var card in cardsforlead)
                {
                    _CardRepository.DeleteCard(card);
                }
                foreach (var appointment in appointmentsforlead)
                {
                    _AppointmentRepository.DeleteAppointmentSheet(appointment);
                }
                foreach (var account in accountsforlead)
                {
                    _AccountRepository.DeleteAccounts(account);
                }

                // leadSuppress.Suppressed = true;
                DeleteLead(leadSuppress);
            }

            return(Redirect("/LeadQueue/Index"));
        }