public ActionResult Edit(Guid? id)
        {
            Association association = new Association();
            if (id != null)
            {
                association = reposetory.GetAssociation((Guid)id);

            }
            else
            {
                association.TeamMessageTeamLeader = DefaultForening.TeamMessageTeamLeader;
                association.TeamMessage = DefaultForening.TeamMessage;
                association.SendTeamText = true;
                association.SendNoteTeamleader = true;
                association.NoteTextTime = Convert.ToInt32(DefaultForening.NoteTextTime);
                association.SendTeamTextDays = Convert.ToInt32(DefaultForening.SendTeamTextDays);
                association.TextServiceProviderUserName = DefaultForening.TextServiceProviderUserName;
                association.TextServiceProviderPassword = DefaultForening.TextServiceProviderPassword;
                association.Scheduletext = DefaultForening.Scheduletext;
                association.Country = Country.DK;
                association.PageSponsor = new Content { Title = DefaultForening.PageContentSponsorTitle, Body = DefaultForening.PageContentSponsor };
                association.PageAbout = new Content { Title = DefaultForening.PageContentAboutTitle, Body = DefaultForening.PageContentAbout };
                association.PagePress = new Content { Title = DefaultForening.PageContentPressTitle, Body = DefaultForening.PageContentPress };
                association.PageLink = new Content { Title = DefaultForening.PageContentLinkTitle, Body = DefaultForening.PageContentLink };
            }

            ViewBag.Networks = reposetory.GetActiveNetworks().Select(d => new SelectListItem { Value = d.NetworkID.ToString(), Text = d.NetworkName }).ToList();

            var SeniorInstructors = reposetory.GetSeniorInstructors().Select(d => new SelectListItem { Value = d.PersonID.ToString(), Text = d.FullName }).ToList();
            SeniorInstructors.Insert(0, new SelectListItem { Value = Guid.Empty.ToString(), Text = General.DropDownChoose });
            ViewBag.SeniorInstructors = SeniorInstructors;

            return View(association);

        }
 public AssociationPagesModel( Association association)
 {
     PageAbout = association.PageAbout;
     PagePress = association.PagePress;
     PageLink = association.PageLink;
     PageSponsor = association.PageSponsor;
     Sponsors = association.Sponsors;
 }
Example #3
0
        public ActionResult Index(Association result)
        {
            Association association = reposetory.GetAssociation(CurrentProfile.AssociationID);
            ModelState.Clear();

            if (Regex.IsMatch(result.KeyBoxcode.Trim().Replace(" ", ""), @"^[a-zA-Z0-9æøåÆØÅ*!#%&]{0,10}$"))
            {
                association.KeyBoxcode = result.KeyBoxcode.Trim().Replace(" ", "");
                ViewBag.FormSucces = true;
                reposetory.SaveAssociation(association);
            }
            else
            {
                ModelState.AddModelError("", @General.ErrorKeybox);
            }

            return View(association);
        }
        public ActionResult Edit(Association association)
        {
            Association CA = new Association();
            if (association.AssociationID != Guid.Empty)
            {
                CA = reposetory.GetAssociation(association.AssociationID);
                if (CA == null) return RedirectToAction("Index");
            }




            if (ModelState.IsValid)
            {
                bool StatusChanged = false;
                CA.Name = association.Name;
                if (CA.Status != association.Status)
                {
                    CA.Status = association.Status; //TODO: Implement notification if Status changes
                    StatusChanged = true;
                }
                CA.Governance = association.Governance;
                CA.AssociationEmail = association.AssociationEmail;
                CA.Number = association.Number;
                CA.URL = association.URL;
                CA.Established = association.Established;
                CA.CVRNR = association.CVRNR;
                CA.TeamPhone = association.TeamPhone;
                CA.ContactPhone = association.ContactPhone;
                CA.Address = association.Address;
                CA.Zip = association.Zip;
                CA.City = association.City;
                CA.TextServiceProviderUserName = association.TextServiceProviderUserName;
                CA.TextServiceProviderPassword = association.TextServiceProviderPassword;
                CA.SendTeamText = association.SendTeamText;
                CA.SendTeamTextDays = association.SendTeamTextDays;
                CA.TeamMessage = association.TeamMessage;
                CA.TeamMessageTeamLeader = association.TeamMessageTeamLeader;
                CA.SendNoteTeamleader = association.SendNoteTeamleader;
                CA.NoteTextTime = association.NoteTextTime;
                CA.Comments = association.Comments;
                CA.Scheduletext = association.Scheduletext.CleanHTML();
                //Setup
                CA.UseSchedulePlanning = association.UseSchedulePlanning;
                CA.UseShiftTeam = association.UseShiftTeam;
                CA.UseTakeTeamSpot = association.UseTakeTeamSpot;
                CA.UseTeamExchange = association.UseTeamExchange;
                CA.UseKeyBox = association.UseKeyBox;
                CA.UseLists = association.UseLists;
                CA.UsePolicePlanning = association.UsePolicePlanning;
                CA.NetworkID = association.NetworkID;
                CA.SeniorInstructorID = association.SeniorInstructorID;
                if (association.SeniorInstructorID == Guid.Empty) CA.SeniorInstructorID = null;

                CA.UsePressPage = association.UsePressPage;
                CA.UseLinksPage = association.UseLinksPage;
                CA.UseSponsorPage = association.UseSponsorPage;


                if (reposetory.SaveAssociation(CA))
                {
                    ViewBag.FormSucces = true;
                    association.AssociationID = CA.AssociationID;
                    ModelState.Clear();
                    if (StatusChanged)
                    {
                        Notification not = reposetory.Notify(CA, String.Format(Notifications.AssociationStatusChanged, CA.Name, CA.Status.DisplayName()));
                        reposetory.NotifyAddAdministration(not);
                        reposetory.NotifyAddAssociation(not, CA.AssociationID);
                        reposetory.NotifySave(not);
                    }
                }

            }
            ViewBag.Networks = reposetory.GetActiveNetworks().Select(d => new SelectListItem { Value = d.NetworkID.ToString(), Text = d.NetworkName }).ToList();

            var SeniorInstructors = reposetory.GetSeniorInstructors().Select(d => new SelectListItem { Value = d.PersonID.ToString(), Text = d.FullName }).ToList();
            SeniorInstructors.Insert(0, new SelectListItem { Value = Guid.Empty.ToString(), Text = General.DropDownChoose });
            ViewBag.SeniorInstructors = SeniorInstructors;

            return View(association);

        }
        public static Association ConvertAssociation(SqlDataReader reader)
        {
            Association association = new Association
            {
                Name = (String)reader["Navn"],
                TeamPhone = ((String)TjekDBNull(reader["Turtelefon"])),

                TeamMessage = (String)TjekDBNull(reader["TurbeskedRavne"]),
                TeamMessageTeamLeader = (String)TjekDBNull(reader["TurbeskedTurleder"]),
                SendTeamTextDays = (int)TjekDBNull(reader["TurSMSdage"]),
                SendNoteTeamleader = (Boolean)TjekDBNull(reader["SendNoteTurleder"]),
                SendTeamText = (Boolean)TjekDBNull(reader["SendturSMS"]),
                NoteTextTime = (int)TjekDBNull(reader["NoteSMStimer"]),
                Scheduletext = (String)TjekDBNull(reader["Turlistetext"]),

                UseLists = (Boolean)TjekDBNull(reader["Lister"]),
                UsePolicePlanning = (Boolean)TjekDBNull(reader["Politi"]),

                UseKeyBox = (Boolean)TjekDBNull(reader["KeyBox"]),
                KeyBoxcode = (String)TjekDBNull(reader["KeyBoxcode"]),

                TextServiceProviderUserName = (String)TjekDBNull(reader["SMSUserName"]),
                TextServiceProviderPassword = (String)TjekDBNull(reader["SMSPassword"]),
                Created = (DateTime)reader["Oprettet"],
                Lastchanged = (DateTime)reader["SidstRettet"]
            };
            association.Trim();
            if (association.Name.Length < 2) association.Name += "  ";
            if (association.Scheduletext.Length < 10) association.Scheduletext = "          ";
            //if (association.Country == String.Empty) association.Country = Country.DK;
            Country tmpCountry;
            if (Enum.TryParse((String)reader["Land"], true, out tmpCountry))
            {
                association.Country = tmpCountry;
            }
            else
            {
                association.Country = Country.DK;
            }

            if (association.TeamMessage.Length < 10) association.TeamMessage = "          ";
            if (association.TeamMessageTeamLeader.Length < 10) association.TeamMessageTeamLeader = "          ";
            //association.URL = new List<string> { association.Name.ValidFileName() };

            return association;
        }
        public ActionResult Edit(Association association)
        {
            Association CA = new Association();
            if (association.AssociationID != Guid.Empty)
            {
                CA = reposetory.GetAssociation(association.AssociationID);
                if (CA == null) return RedirectToAction("Index");
            }

            if (ModelState.ContainsKey("Name")) ModelState["Name"].Errors.Clear(); 

            if (ModelState.IsValid)
            {
                bool StatusChanged = false;
                //CA.Name = association.Name;
                //if (CA.Status != association.Status)
                //{
                //    CA.Status = association.Status; //TODO: Implement notification if Status changes
                //    StatusChanged = true;
                //}
                //CA.Governance = association.Governance;
                CA.AssociationEmail = association.AssociationEmail;
                //CA.Established = association.Established;
                CA.CVRNR = association.CVRNR;
                CA.TeamPhone = association.TeamPhone;
                CA.ContactPhone = association.ContactPhone;
                CA.Address = association.Address;
                CA.Zip = association.Zip;
                CA.City = association.City;
                CA.TextServiceProviderUserName = association.TextServiceProviderUserName;
                CA.TextServiceProviderPassword = association.TextServiceProviderPassword;
                CA.SendTeamText = association.SendTeamText;
                CA.SendTeamTextDays = association.SendTeamTextDays;
                CA.TeamMessage = association.TeamMessage;
                CA.TeamMessageTeamLeader = association.TeamMessageTeamLeader;
                CA.SendNoteTeamleader = association.SendNoteTeamleader;
                CA.NoteTextTime = association.NoteTextTime;
                CA.Comments = association.Comments;
                CA.Scheduletext = association.Scheduletext.CleanHTML();
                //Setup
                CA.UseSchedulePlanning = association.UseSchedulePlanning;
                CA.UseShiftTeam = association.UseShiftTeam;
                CA.UseTakeTeamSpot = association.UseTakeTeamSpot;
                CA.UseTeamExchange = association.UseTeamExchange;
                CA.UseKeyBox = association.UseKeyBox;
                CA.UseLists = association.UseLists;
                CA.UsePolicePlanning = association.UsePolicePlanning;
                CA.DeadlineHoursTeamChange = association.DeadlineHoursTeamChange;
                CA.UsePressPage = association.UsePressPage;
                CA.UseLinksPage = association.UseLinksPage;
                CA.UseSponsorPage = association.UseSponsorPage;





                if (reposetory.SaveAssociation(CA))
                {
                    ViewBag.FormSucces = true;
                    if (StatusChanged)
                    {
                        Notification not = reposetory.Notify(CA, String.Format(Notifications.AssociationStatusChanged, CA.Name, CA.Status.DisplayName()));
                        reposetory.NotifyAddAdministration(not);
                        reposetory.NotifyAddAssociation(not, CA.AssociationID);
                        reposetory.NotifySave(not);
                    }
                }

            }

            return View(association);

        }