Beispiel #1
0
        public ActionResult Edit(Lead lead)
        {
            Lead dbLead = new Lead();

            if (lead.LeadID != Guid.Empty)
            {
                dbLead = reposetory.GetLead(lead.LeadID);
                if (dbLead == null)
                {
                    return(RedirectToAction("Index"));
                }
            }

            if (ModelState.IsValid)
            {
                LeadStatus oldStatus = dbLead.Status;



                dbLead.FirstName         = lead.FirstName;
                dbLead.FamilyName        = lead.FamilyName;
                dbLead.Status            = lead.Status;
                dbLead.AssociationID     = lead.AssociationID == Guid.Empty ? null : lead.AssociationID;
                dbLead.Address           = lead.Address;
                dbLead.City              = lead.City;
                dbLead.Zip               = lead.Zip;
                dbLead.Phone             = lead.Phone;
                dbLead.Mobile            = lead.Mobile;
                dbLead.Email             = lead.Email;
                dbLead.Age               = lead.Age;
                dbLead.Comments          = lead.Comments;
                dbLead.RequestUpdateMail = false;

                if (reposetory.Save(dbLead))
                {
                    if ((oldStatus == LeadStatus.New | oldStatus == LeadStatus.Acknowledge |
                         oldStatus == LeadStatus.Clarification | lead.LeadID == Guid.Empty)
                        & dbLead.Status == LeadStatus.Assigned & dbLead.AssociationID != null)
                    {
                        string        to = string.Empty;
                        List <string> cc = new List <string>();

                        AccessModel Access = reposetory.GetAccess((Guid)dbLead.AssociationID);

                        BoardModelView Board = reposetory.GetBoardView((Guid)dbLead.AssociationID);

                        to = string.Format("{0} <{1}>", Board.Chairmann.FullName, Board.Chairmann.Email);

                        foreach (PersonAccess M in Access.Form)
                        {
                            if (M.Secretary)
                            {
                                NRMembership p = reposetory.GetMembership(M.FunctionID);
                                //cc += string.Format("{0},", p.Person.Email);
                                cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                            }
                            else if (M.Planner)
                            {
                                NRMembership p = reposetory.GetMembership(M.FunctionID);
                                //cc += string.Format("{0},", p.Person.Email);
                                cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                            }
                        }



                        var mail = new LeadAssign
                        {
                            to   = to,
                            cc   = cc,
                            lead = dbLead
                        };

                        //return new EmailViewResult(mail);

                        mail.Send();
                    }
                    lead.LeadID = dbLead.LeadID;
                    ModelState.Clear();


                    ViewBag.FormSucces = true;
                }
            }

            List <AssociationListModel> tmp = reposetory.GetAssociationList(); //.RemoveAll(item => CU.Memberships.ToList().Exists(p => p.Association.AssociationID == item.AssociationID));

            ViewBag.Attach = new SelectList(tmp, "AssociationID", "Name");
            return(View(lead));
        }
Beispiel #2
0
        public ActionResult StatusUpdateRequest(Guid ID)
        {
            Lead dbLead = new Lead();

            dbLead = reposetory.GetLead(ID);
            if (dbLead == null)
            {
                return(null);
            }
            if (dbLead.AssociationID == null)
            {
                return(null);
            }


            dbLead.RequestUpdateMail = true;

            if (reposetory.Save(dbLead))
            {
                if (dbLead.AssociationID != null)
                {
                    string        to = string.Empty;
                    List <string> cc = new List <string>();

                    AccessModel Access = reposetory.GetAccess((Guid)dbLead.AssociationID);

                    BoardModelView Board = reposetory.GetBoardView((Guid)dbLead.AssociationID);

                    to = string.Format("{0} <{1}>", Board.Chairmann.FullName, Board.Chairmann.Email);

                    foreach (PersonAccess M in Access.Form)
                    {
                        if (M.Secretary)
                        {
                            NRMembership p = reposetory.GetMembership(M.FunctionID);
                            //cc += string.Format("{0},", p.Person.Email);
                            cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                        }
                        else if (M.Planner)
                        {
                            NRMembership p = reposetory.GetMembership(M.FunctionID);
                            //cc += string.Format("{0},", p.Person.Email);
                            cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                        }
                    }



                    var mail = new LeadRequestUpdate
                    {
                        to   = to,
                        cc   = cc,
                        lead = dbLead
                    };

                    //return new EmailViewResult(mail);

                    mail.Send();
                }



                ViewBag.FormSucces = true;
            }

            return(RedirectToAction("Index"));
        }