예제 #1
0
        public ActionResult MakeAbsent(Guid Id)
        {
            NRMembership CU = reposetory.GetMembership(Id);

            if (CU == null)
            {
                return(HttpNotFound());
            }

            if (CU.Person.PersonID != CurrentProfile.PersonID)
            {
                CU.AbsentDate = DateTime.Now;
                CU.Editor     = false;
                CU.Secretary  = false;
                CU.Planner    = false;
                reposetory.SavePerson(CU);
            }

            return(RedirectToAction("Edit", new { id = Id }));
        }
예제 #2
0
        public ActionResult MakeAbsent(Guid Id)
        {
            NRMembership CU = reposetory.GetMembership(Id);

            if (CU == null)
            {
                return(HttpNotFound());
            }

            if (CU.Person.PersonID != CurrentProfile.PersonID && CU.BoardFunction == BoardFunctionType.none)
            {
                CU.AbsentDate = DateTime.Now;
                CU.Editor     = false;
                CU.Secretary  = false;
                CU.Planner    = false;
                reposetory.SavePerson(CU);
            }

            return(RedirectToAction("Index"));
        }
예제 #3
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));
        }
예제 #4
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"));
        }
예제 #5
0
        public ActionResult Edit(NRMembership Membership, string RadioGender, string Action)
        {
            NRMembership CU = new NR.Models.NRMembership
            {
                AssociationID = CurrentProfile.AssociationID,
                SignupDate    = DateTime.Now,
                Type          = PersonType.Active
            };

            CU.Person = new Person();
            if (Membership.MembershipID != Guid.Empty)
            {
                CU = reposetory.GetMembership(Membership.MembershipID);
                if (CU == null)
                {
                    return(HttpNotFound());
                }
            }

            //Check for a uniq username against database
            if (Membership.Person.PersonID == Guid.Empty || (Membership.Person.UserName != CU.Person.UserName))
            {
                if (String.IsNullOrWhiteSpace(Membership.Person.UserName) | !reposetory.IsUserNameUniqe(Membership.Person.UserName))
                {
                    string SuggestedUserName = Membership.Person.UserName;
                    if (Membership.Person.PersonID == Guid.Empty)
                    {
                        reposetory.GenerateUniqueUserName(Membership.Person);
                        ModelState.SetModelValue("Person.UserName", new ValueProviderResult(Membership.Person.UserName, Membership.Person.UserName.ToString(), CultureInfo.InvariantCulture));
                        if (!String.IsNullOrWhiteSpace(SuggestedUserName))
                        {
                            ModelState.AddModelError("Person.UserName", string.Format(DomainStrings.UserNameNotUniqueSuggestion, SuggestedUserName));
                        }
                    }
                    else
                    {
                        Membership.Person.UserName = CU.Person.UserName;
                        //ModelState.Clear();
                        ModelState.SetModelValue("Person.UserName", new ValueProviderResult(Membership.Person.UserName, Membership.Person.UserName.ToString(), CultureInfo.InvariantCulture));
                        ModelState.AddModelError("Person.UserName", string.Format(DomainStrings.UserNameNotUnique, SuggestedUserName));
                    }
                }
            }

            if (RadioGender == "M")
            {
                Membership.Person.Gender = Gender.Man;
            }
            if (RadioGender == "F")
            {
                Membership.Person.Gender = Gender.Woman;
            }
            Membership.Person.Trim();
            if (CU.Person.MailUndeliverable && (
                    CU.Person.FirstName != Membership.Person.FirstName |
                    CU.Person.FamilyName != Membership.Person.FamilyName |
                    CU.Person.Address != Membership.Person.Address |
                    CU.Person.City != Membership.Person.City |
                    CU.Person.Zip != Membership.Person.Zip
                    ))
            {
                CU.Person.MailUndeliverable     = false;
                CU.Person.MailUndeliverableDate = null;
            }
            CU.Person.UserName          = Membership.Person.UserName;
            CU.Type                     = Membership.Type;
            CU.Person.FirstName         = Membership.Person.FirstName;
            CU.Person.FamilyName        = Membership.Person.FamilyName;
            CU.Person.Address           = Membership.Person.Address;
            CU.Person.City              = Membership.Person.City;
            CU.Person.Zip               = Membership.Person.Zip;
            CU.Person.Email             = Membership.Person.Email;
            CU.SignupDate               = Membership.SignupDate;
            CU.Person.Country           = Membership.Person.Country;
            CU.Person.Mobile            = Membership.Person.Mobile;
            CU.Person.Phone             = Membership.Person.Phone;
            CU.Person.BasicTrainingDate = Membership.Person.BasicTrainingDate;
            CU.Person.BirthDate         = Membership.Person.BirthDate;
            CU.Person.EmailNewsLetter   = Membership.Person.EmailNewsLetter;
            CU.Person.PrintNewslettet   = Membership.Person.PrintNewslettet;
            CU.Person.Gender            = Membership.Person.Gender;
            CU.Teamleader               = Membership.Teamleader;
            CU.Note                     = Membership.Note;

            if (String.IsNullOrWhiteSpace(CU.Person.Password))
            {
                CU.Person.Password = String.Empty.GeneratePassword();
            }

            if (ModelState.IsValid)
            {
                var refresh = Membership.Person.PersonID == Guid.Empty;
                reposetory.SavePerson(CU);

                //TODO: Remove Websecurity account if status is changed from Active

                if (refresh)
                {
                    //ensure that form i updated if resubmit of form i done
                    //ModelState.SetModelValue("MembershipID", new ValueProviderResult(CU.MembershipID, CU.MembershipID.ToString(), CultureInfo.InvariantCulture));
                    //ModelState.SetModelValue("Person.PersonID", new ValueProviderResult(CU.Person.PersonID, CU.Person.PersonID.ToString(), CultureInfo.InvariantCulture));

                    //Create Websecurity Memebership if account is active
                    if (CU.Type == PersonType.Active)
                    {
                        if (!WebSecurity.IsConfirmed(CU.Person.UserName))
                        {
                            WebSecurity.CreateAccount(CU.Person.UserName, CU.Person.Password);
                        }

                        //Send Welcome mail if user has an E-mail
                        if (!String.IsNullOrWhiteSpace(CU.Person.Email))
                        {
                            var mail = new WelcomeMailEmail
                            {
                                To       = CU.Person.Email,
                                UserName = CU.Person.UserName,
                                Password = CU.Person.Password
                            };
                            mail.Send();
                        }
                        else if (!String.IsNullOrWhiteSpace(CU.Person.Mobile))
                        {
                            Association association = reposetory.GetAssociation(CU.Person.CurrentAssociation);

#if DUMMYTEXT
                            ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance("NR.Infrastructure.DummyTextGateway", association == null ? null : association.TextServiceProviderUserName, association == null ? null : association.TextServiceProviderPassword);
#else
                            ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(association.TextServiceProvider, association == null ? null : association.TextServiceProviderUserName, association == null ? null : association.TextServiceProviderPassword);
#endif


                            SMSGateway.FromText  = General.SystemTextMessagesFrom;
                            SMSGateway.Message   = String.Format(General.SystemTextMessagesWelcome, CU.Person.UserName, CU.Person.Password);
                            SMSGateway.Recipient = new List <Person> {
                                CU.Person
                            };
                            if (association != null)
                            {
                                reposetory.NewTextMessage(SMSGateway, association.AssociationID);
                                SMSGateway.HandShakeUrl = Url.Action("TextXStatus", "Account", new { ID = SMSGateway.TextId }, "http");
                            }

                            if (SMSGateway.Send())
                            {
                            }
                            ;
                        }

                        Notification not = reposetory.Notify(CU.Person, String.Format(Notifications.NewPerson, CU.Person.FullName));
                        reposetory.NotifyAddAdministration(not);
                        reposetory.NotifyAddAssociation(not, CU.AssociationID);

                        reposetory.NotifySave(not);
                    }
                }
                ModelState.Clear();
                ViewBag.FormSucces = true;
                return(View(CU));
            }
            return(View(Membership));
        }
예제 #6
0
        private static void CheckData()
        {
            if (HttpContext.Current.Session == null || !WebSecurity.IsAuthenticated)
            {
                Clear();
                return;
            }
            if (HttpContext.Current.Session["UserID"] != null && (int)HttpContext.Current.Session["UserID"] == WebSecurity.CurrentUserId)
            {
                return;
            }

            Clear();

            using (var dbContext = new Repository())
            {
                Person       person     = dbContext.People.Where(p => p.UserID == WebSecurity.CurrentUserId).FirstOrDefault();
                NRMembership membership = null;

                if (person != null)
                {
                    if (person.CurrentAssociation != Guid.Empty)
                    {
                        membership = dbContext.Memberships.Where(m => m.Person.PersonID == person.PersonID & m.Association.AssociationID == person.CurrentAssociation).Include(m => m.Association).FirstOrDefault();
                    }

                    if (membership == null)
                    {
                        membership = (from m in dbContext.Memberships where m.Person.PersonID == person.PersonID & m.AbsentDate == null select m).Include(m => m.Association).FirstOrDefault();
                    }

                    if (membership != null && membership.Association != null && person.CurrentAssociation != membership.Association.AssociationID)
                    {
                        person.CurrentAssociation = membership.AssociationID;

                        dbContext.Entry(person).State = EntityState.Modified;
                        dbContext.SaveChanges();
                    }


                    HttpContext.Current.Session["UserID"]             = person.UserID;
                    HttpContext.Current.Session["Username"]           = person.UserName;
                    HttpContext.Current.Session["Email"]              = person.Email;
                    HttpContext.Current.Session["Mobile"]             = person.Mobile;
                    HttpContext.Current.Session["PersonID"]           = person.PersonID;
                    HttpContext.Current.Session["isSeniorInstructor"] = person.SeniorInstructor;

                    HttpContext.Current.Session["ListLines"]         = person.ListLines < 10 ? 10 : person.ListLines;
                    HttpContext.Current.Session["EmailNewsLetter"]   = person.EmailNewsLetter;
                    HttpContext.Current.Session["PrintNewslettet"]   = person.PrintNewslettet;
                    HttpContext.Current.Session["MailUndeliverable"] = person.MailUndeliverable;


                    if (membership != null && !membership.Absent && membership.Association != null)
                    {
                        HttpContext.Current.Session["hasMembership"] = true;

                        HttpContext.Current.Session["AssociationID"]               = membership.AssociationID;
                        HttpContext.Current.Session["AssociationName"]             = membership.Association.Name;
                        HttpContext.Current.Session["TextServiceProvider"]         = membership.Association.TextServiceProvider;
                        HttpContext.Current.Session["TextServiceProviderUserName"] = membership.Association.TextServiceProviderUserName;
                        HttpContext.Current.Session["TextServiceProviderPassword"] = membership.Association.TextServiceProviderPassword;

                        HttpContext.Current.Session["NetworkID"] = membership.Association == null ? Guid.Empty : membership.Association.NetworkID;

                        HttpContext.Current.Session["isTeamleader"] = membership.Teamleader;
                        HttpContext.Current.Session["isPlanner"]    = membership.Planner;
                        HttpContext.Current.Session["isSecretary"]  = membership.Secretary;
                        HttpContext.Current.Session["isEditor"]     = membership.Editor;


                        HttpContext.Current.Session["usePlanning"]     = membership.Association.UseSchedulePlanning;
                        HttpContext.Current.Session["useTakeTeamSpot"] = membership.Association.UseTakeTeamSpot;
                        HttpContext.Current.Session["UseKeyBox"]       = membership.Association.UseKeyBox;
                    }
                }
            }
        }