Пример #1
0
        public ActionResult PreViewEmailMessagNotification(string name)
        {
            Person P = new Person
            {
                FirstName = "Hej",
                FamilyName = "EfetrHej"
            };
            
            
            MessagNotification email = new MessagNotification();
            // set up the email ...
            email.To = "*****@*****.**";
            email.Subject = "Test emne";
            email.ReplyTo = "dan@Taxbol";
            email.Message = "em længere beskede der måske kan indholde <strong>Html</strong>";
            email.Link = "http://eteelrande";
            email.FromPerson = P;
            //email.folder = reposetory.GetFolder(new Guid("9b93e5c0-7caf-e411-bf26-c485084553de"));
            //email.Person = reposetory.GetPerson(new Guid("983504df-3e8b-4af7-a54d-308090a74a02"));
            //email.message = "test besked på at det virker atgsepråer";
            //email.ReplyToList.Add("*****@*****.**");
            email.Send();
            return new EmailViewResult(email);

        }
Пример #2
0
 public DisplayProfile(Person person)
 {
     if (person == null) throw new ArgumentNullException("Person object null"); 
     Person = person;
     Activity = null;
     ActiveSince = null;
     CurrentMembership = Person.Memberships.Where(x => x.Person.CurrentAssociation == x.AssociationID).FirstOrDefault();
     if (person.DeltaActivity != 0 | (person.Teams != null && person.Teams.Any())) Activity = person.Teams.Where(t => t.Status == TeamStatus.OK).Count() + person.DeltaActivity;
     if (person.Memberships != null && person.Memberships.Any()) ActiveSince = (Person.Memberships.Aggregate((curmin, x) => (curmin == null || (x.SignupDate ?? DateTime.MaxValue) < curmin.SignupDate ? x : curmin))).SignupDate;
 }
Пример #3
0
        public PrintMailingModel(Person P)
        {
            ID = P.PersonID.ToString().Replace("-","");
            UserName = P.UserName.Trim(); 
            FirstName = P.FirstName.TrimAndReduce();
            FamilyName = P.FamilyName.TrimAndReduce();
            Address = P.Address.TrimAndReduce();
            Zip = P.Zip.TrimAndReduce();
            City = P.City.TrimAndReduce();
            Country = P.Country;

        }
Пример #4
0
        public static string ReplaceTagTeamMembers(this string value, Team team, Person currentPerson)
        {
            if (string.IsNullOrWhiteSpace(value)) return value;

            string result = "";

            foreach (Person P in team.Teammembers.ToList().Where(x => x.PersonID != currentPerson.PersonID).OrderBy(m => String.Concat(m.FirstName, " ", m.FamilyName)))
            {
                if (result != "") result += ", ";
                result += P.FirstName + " ( ";
                result += P.Mobile == "" ? "--" : P.Mobile;
                result += " )";
            }

            
           

            return value.Replace(TeamMembers, result);
        }
Пример #5
0
        public PersonAdminList(Person person)
        {
            PersonID = person.PersonID;
            UserName = person.UserName;
            Email = person.Email;
            FullName = person.FullName;
            Mobile = person.Mobile;
            Phone = person.Phone;
            if (person.Memberships.Any())
            {
                String StrAssociation = "";
                foreach (NRMembership m in person.Memberships)
                {
                    StrAssociation += m.Association.Name + ", ";
                };
                StrAssociation = StrAssociation.Substring(0, StrAssociation.Length - 2);
                Association = StrAssociation;
            }

            Attributes = HtmlExtensions.PersonOnlyAttributesIcons(person);
        }
Пример #6
0
        //***********************************************************************************

        public static Guid MigrateAssociation(int id)
        {
            Guid assID = Guid.Empty;
            Dictionary<string, DateTime> PersonCreated = new Dictionary<string, DateTime>();
            Dictionary<string, Guid> PersonGuid = new Dictionary<string, Guid>();


            using (var context = new Repository())
            {
                StringBuilder SQLIdentity = new StringBuilder();
                Association ass = ExtractAssociation(id);
                System.Diagnostics.Debug.WriteLine("Start migrating Association: \"" + ass.Name + "\"");
                progress += String.Format("<br/>Start migrating Association: \"{0}\"", ass.Name.ToString());

                DateTime Created = ass.Created;

                SeedData rec = Seed.Find(n => n.Name.ToLower() == ass.Name.ToLower());
                if (rec != null)
                {
                    ass.Network = context.Networks.Where(n => n.NetworkNumber == rec.Network).FirstOrDefault();
                    ass.Established = rec.EstablishedDT;
                    if (!String.IsNullOrWhiteSpace(rec.NewName)) ass.Name = rec.NewName;
                    ass.Number = rec.Number;
                    ass.Governance = rec.Governance;
                }
                else
                {
                    progress += String.Format("<br/><span style=\"color: red\">No Migration Default for Association: \"{0}\"</span>", ass.Name.ToString());
                    ass.Network = context.Networks.Where(n => n.NetworkNumber == 99).FirstOrDefault();
                }

                foreach (NRMembership m in ass.Memberships)
                {
                    PersonCreated.Add(m.Person.UserName, m.Person.Created);
                    PersonGuid.Add(m.Person.UserName, m.Person.PersonID);
                    var tmpPerson = new Person
                    {
                        UserName = m.Person.UserName,
                        FirstName = "Test",
                        FamilyName = "Test",
                        Address = "Test",
                        City = "Test",
                        Zip = "Test"
                    };
                    context.Entry(tmpPerson).State = EntityState.Added;

                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("{0} Exception caught.", e));
                    }

                    StringBuilder SQLIdentityPerson = new StringBuilder();
                    Created = (DateTime)PersonCreated[m.Person.UserName.ToString()];
                    Guid Gid = (Guid)PersonGuid[m.Person.UserName.ToString()];
                    SQLIdentityPerson.AppendLine(string.Format("UPDATE [People] SET Created = '{0}' WHERE Username = '******';", Created.ToString("yyyy-MM-dd hh:mm:ss.mmm"), m.Person.UserName.ToString()));
                    SQLIdentityPerson.AppendLine(string.Format("UPDATE [People] SET PersonID = '{0}' WHERE Username = '******';", Gid.ToString(), m.Person.UserName.ToString()));
                    context.Database.ExecuteSqlCommand(SQLIdentityPerson.ToString());

                    if (rec != null)
                    {
                        if (m.Person.UserName == rec.Chairmann)
                        { m.BoardFunction = BoardFunctionType.Chairman; }
                        else if (m.Person.UserName == rec.Accountant)
                        { m.BoardFunction = BoardFunctionType.Accountant; }
                        else if (m.Person.UserName == rec.Auditor)
                        { m.BoardFunction = BoardFunctionType.Auditor; }
                        else if (m.Person.UserName == rec.AuditorAlternate)
                        { m.BoardFunction = BoardFunctionType.AuditorAlternate; }
                        else if (rec.BoardMembers != null && rec.BoardMembers.Contains(m.Person.UserName))
                        { m.BoardFunction = BoardFunctionType.BoardMember; }
                        else if (rec.Alternate != null && rec.Alternate.Contains(m.Person.UserName))
                        { m.BoardFunction = BoardFunctionType.Alternate; }
                    }

                    context.Entry(m.Person).State = EntityState.Modified;
                    System.Diagnostics.Debug.WriteLine("  - (" + ass.Name + ") [" + m.Person.FullName + "]");
                    progress += String.Format("<br/> - ({0}) [{1}]", ass.Name.ToString(), m.Person.FullName);

                    try
                    {
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("  - Error Migrating (" + ass.Name + ") [" + m.Person.FullName + "]");
                        System.Diagnostics.Debug.WriteLine(string.Format("{0} Exception caught.", e));
                    }

                    if (!m.Absent) //&& !WebSecurity.UserExists(m.Person.UserName))
                    {
                        WebSecurity.CreateAccount(m.Person.UserName, m.Person.Password);
                        if (WebSecurity.ConfirmAccount(m.Person.UserName))
                        {
                            System.Diagnostics.Debug.WriteLine("**Migrating Person: \"" + m.Person.UserName + "\" / (" + m.Person.Password + ")");
                        }

                        var img = DownloadImageFromUrl(string.Format("http://www.ravnetur.dk/Natteravnebilleder/{0}.jpg", m.Person.PersonID));

                        if (img != null)
                        {
                            string newFileName = string.Format(ProfilDirSetting, m.Person.PersonID.ToString());
                            string newFileLocation = newFileName;
                            if (Directory.Exists(Path.GetDirectoryName(newFileLocation)) == false)
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(newFileLocation));
                            }

                            img.Save(newFileLocation);
                            progress += " - Image transferred";
                        }
                    }
                }
                System.Diagnostics.Debug.WriteLine("  - Saving (" + ass.Name + ")");
                context.Entry(ass).State = EntityState.Added;

                try
                {
                    context.SaveChanges();
                    assID = ass.AssociationID;
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("  - Error saving (" + ass.Name + ")");
                    System.Diagnostics.Debug.WriteLine(string.Format("{0} Exception caught.", e));
                    System.Diagnostics.Debug.WriteLine("-------------------------------------------------------------------------------------------");
                    System.Diagnostics.Debug.WriteLine(string.Format("{0} Exception caught.", e.InnerException));


                }

                context.Memberships.Where(m => m.Association.AssociationID == ass.AssociationID)
                    .ToList()
                    .ForEach(p => p.Person.CurrentAssociation = p.Association.AssociationID);
                context.SaveChanges();


                //SQLIdentity.AppendLine("SET IDENTITY_INSERT [Associations] ON;");
                SQLIdentity.AppendLine(string.Format("UPDATE [Associations] SET Created = '{0}' WHERE AssociationID = '{1}';", Created.ToString("yyyy-MM-dd hh:mm:ss.mmm"), ass.AssociationID.ToString()));
                //SQLIdentity.AppendLine("SET IDENTITY_INSERT [Associations] OFF;");


                context.Database.ExecuteSqlCommand(SQLIdentity.ToString());



            }
            return assID;
        }
Пример #7
0
        public static void GenerateUniqUsername(Person person)
        {
            string UserName;
            string Ftxt = String.IsNullOrWhiteSpace(person.FirstName) ? "" : Regex.Replace(person.FirstName.ToUpper(), @"[^A-Z0-9ÆØÅ]", "");
            string Ltxt = String.IsNullOrWhiteSpace(person.FamilyName) ? "" : Regex.Replace(person.FamilyName.ToUpper(), @"[^A-Z0-9ÆØÅ]", "");
            StringBuilder Extra = new StringBuilder();
            int Fno = Ftxt.Length > 1 ? 1 : Ftxt.Length;
            int Lno = Ltxt.Length > 2 ? 2 : Ltxt.Length;
            int ULength = 3;

            do
            {
                ULength += 1;
                if ((Lno > Fno | Fno == Ltxt.Length) & Fno < Ftxt.Length)
                { Fno += 1; }
                else if (Lno < Ltxt.Length)
                { Lno += 1; }

                if (Fno + Lno < ULength)
                {
                    Random random = new Random();
                    char ch;
                    for (int i = 0; i < ULength - Lno - Fno; i++)
                    {
                        ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                        Extra.Append(ch);
                    }
                }

                UserName = Ftxt.Substring(0, Fno).ToUpper() + Ltxt.Substring(0, Lno).ToUpper() + Extra.ToString().ToUpper();


            } while (WebSecurity.GetUserId(UserName) > 0);

            person.UserName = UserName;

        }
Пример #8
0
        public static Person ConvertPerson(SqlDataReader reader, Country country)
        {
            var personen = new Person();
            personen.PersonID = (Guid)reader["UserId"];
            personen.Email = reader["Email"] == DBNull.Value ? "" : ((String)reader["Email"]);
            personen.UserName = ((String)reader["UserName"]);
            personen.Password = reader["Password"] == DBNull.Value ? "" : (String)reader["Password"];
            personen.FirstName = ReturnProperty("Fornavn", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.FamilyName = ReturnProperty("Efternavn", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.Address = ReturnProperty("Vej", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.City = ReturnProperty("By", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.Zip = ReturnProperty("Postnr", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.Phone = ReturnProperty("Telefon", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.Mobile = ReturnProperty("Mobil", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            String Koen = ReturnProperty("gender", (string)reader["PropertyNames"], (string)reader["PropertyValuesString"]);
            personen.Created = (DateTime)reader["CreateDate"];

            personen.Gender = Gender.NotDefined;
            if (Koen == "K") personen.Gender = Gender.Woman;
            if (Koen == "M") personen.Gender = Gender.Man;
            personen.Trim();

            personen.Country = country;
            if (string.IsNullOrWhiteSpace(personen.Phone) | personen.Phone.Length < 8) personen.Phone = String.Empty;
            if (string.IsNullOrWhiteSpace(personen.Mobile) | personen.Mobile.Length < 8) personen.Mobile = String.Empty;
            if (personen.Address.Length < 2) personen.Address = "  ";
            if (personen.Address.Length > 70) personen.Address = personen.Address.Substring(0, 70);
            if (personen.City.Length < 2) personen.City = "  ";
            if (personen.Zip.Length < 2) personen.Zip = "  ";
            if (personen.FirstName.Length < 2) personen.FirstName = "**";
            if (personen.FamilyName.Length < 2) personen.FamilyName = "**";

            if (personen.UserName.Length > 10 || Regex.Replace(personen.UserName, @"[^A-Z0-9ÆØÅ]", "") != personen.UserName || WebSecurity.GetUserId(personen.UserName) > 0)
                GenerateUniqUsername(personen);

            if (!string.IsNullOrEmpty(personen.Email) && !Regex.IsMatch(personen.Email, @"^(['\""]{1,}.+['\""]{1,}\s+)?<?[\w\.\-]+@([\w\-]+\.)+[A-Za-z]{2,}>?$"))
                personen.Email = "";

            var results = new List<ValidationResult>();
            var context = new ValidationContext(personen, null, null);
            if (!Validator.TryValidateObject(personen, context, results))
            {
                foreach (ValidationResult res in results)
                {
                    System.Diagnostics.Debug.WriteLine("ModelFaileur: " + res.ErrorMessage);

                }
            }

            return personen;
        }
Пример #9
0
        public static void MigrateAssociation(int id)
        {
            #region SEEDDATA


            List<SeedData> Seed = new List<SeedData>{
                            new SeedData { Name = "Haslev", Number = 44, Network = 12, Established = "29-1-2001",
                            Governance = GovernanceType.Traditionel,
                            Chairmann ="DTA",
                            Auditor = "PECH",
                            Accountant = "JEDY",
                            BoardMembers = new List<string> 
                            { "KULA", "ULHA", "RIWI", "SUKI", "CLSM" }
                            },
                            
                            
                            
                            
                            new SeedData { Name = "Albertslund", Number = 217, Network = 15, Established = "26-1-2009"},
                            new SeedData { Name = "Almind", Number = 167, Network = 8, Established = "3-2-2011"},
                            new SeedData { Name = "Ansager (Ølgod)", Number = 199, Network = 6, Established = "?"},
                            new SeedData { Name = "Arden", Number = 65, Network = 2, Established = "5-9-2001"},
                            new SeedData { Name = "Askerød (Greve)", Number = 220, Network = 16, Established = "21-11-2008"},
                            new SeedData { Name = "Assens", Number = 72, Network = 9, Established = "26-9-2001"},
                            new SeedData { Name = "Ballerup", Number = 70, Network = 0, Established = "24-9-2001"},
                            new SeedData { Name = "Billund", Number = 118, Network = 6, Established = "26-3-2003"},
                            new SeedData { Name = "Birkerød", Number = 189, Network = 10, Established = "25-10-2006"},
                            new SeedData { Name = "Bispebjerg", Number = 179, Network = 14, Established = "5-4-2006"},
                            new SeedData { Name = "Bispehaven", Number = 48, Network = 4, Established = "21-2-2001"},
                            new SeedData { Name = "Bispehavens Kvindegruppe", Number = 251, Network = 4, Established = "11-6-2010"},
                            new SeedData { Name = "Bjerringbro", Number = 27, Network = 3, Established = "18-9-2000"},
                            new SeedData { Name = "Blaabjerg (Varde)", Number = 114, Network = 6, Established = "27-1-2003"},
                            new SeedData { Name = "Bogense", Number = 143, Network = 9, Established = "26-8-2004"},
                            new SeedData { Name = "Bramming", Number = 94, Network = 6, Established = "27-5-2002"},
                            new SeedData { Name = "Bramsnæs", Number = 210, Network = 11, Established = "23-8-2008"},
                            new SeedData { Name = "Brande", Number = 159, Network = 5, Established = "27-4-2005"},
                            new SeedData { Name = "Brandrupdam (Kolding)", Number = 216, Network = 8, Established = "7-10-2008"},
                            new SeedData { Name = "Brovst", Number = 151, Network = 1, Established = "28-10-2004"},
                            new SeedData { Name = "Brædstrup (Horsens)", Number = 264, Network = 8, Established = "28-12-2012"},
                            new SeedData { Name = "Brøndby Strand", Number = 43, Network = 16, Established = "23-1-2001"},
                            new SeedData { Name = "Brøndbyøster", Number = 121, Network = 15, Established = "12-5-2003"},
                            new SeedData { Name = "Brønderslev", Number = 37, Network = 1, Established = "7-11-2000"},
                            new SeedData { Name = "Brønshøj ", Number = 226, Network = 14, Established = "9-3-2009"},
                            new SeedData { Name = "Brønshøj-Husum", Number = 58, Network = 14, Established = "19-4-2001"},
                            new SeedData { Name = "Brønshøj-Husum", Number = 0, Network = 14, Established = "9-3-2009"},
                            new SeedData { Name = "Brørup", Number = 156, Network = 6, Established = "10-3-2005"},
                            new SeedData { Name = "Børkop", Number = 207, Network = 8, Established = "21-3-2005"},
                            new SeedData { Name = "Christiansfeld", Number = 135, Network = 8, Established = "18-3-2004"},
                            new SeedData { Name = "Dalby", Number = 191, Network = 12, Established = "12-3-2007"},
                            new SeedData { Name = "De etniske kvinder i Kbh.", Number = 200, Network = 14, Established = "31-10-2007"},
                            new SeedData { Name = "Den grønne Trekant", Number = 184, Network = 14, Established = "21-6-2006"},
                            new SeedData { Name = "Dronninglund", Number = 18, Network = 1, Established = "10-6-2000"},
                            new SeedData { Name = "Ebeltoft", Number = 136, Network = 4, Established = "23-3-2004"},
                            new SeedData { Name = "Esbjerg", Number = 267, Network = 6, Established = "12-3-2014"},
                            new SeedData { Name = "Esbjerg City", Number = 6, Network = 6, Established = "4-10-1999"},
                            new SeedData { Name = "Espergærde (Helsingør)", Number = 194, Network = 10, Established = "11-5-2007"},
                            new SeedData { Name = "Fakse og Ladepladsen", Number = 76, Network = 12, Established = "26-11-2001"},
                            new SeedData { Name = "Fakseladeplads", Number = 19, Network = 12, Established = "13-6-2000"},
                            new SeedData { Name = "Farsø", Number = 74, Network = 2, Established = "13-1-2001"},
                            new SeedData { Name = "Farum", Number = 176, Network = 10, Established = "7-3-2006"},
                            new SeedData { Name = "Fjerritslev", Number = 175, Network = 1, Established = "7-3-2006"},
                            new SeedData { Name = "Folehaven", Number = 174, Network = 14, Established = "22-2-2006"},
                            new SeedData { Name = "Fredericia", Number = 113, Network = 8, Established = "3-12-2002"},
                            new SeedData { Name = "Fredericia Vest (Fredericia)", Number = 248, Network = 8, Established = "12-5-2010"},
                            new SeedData { Name = "Frederiksberg", Number = 221, Network = 14, Established = "27-11-2008"},
                            new SeedData { Name = "Frederikshavn (Skagen)", Number = 23, Network = 1, Established = "31-8-2000"},
                            new SeedData { Name = "Frederikssund", Number = 81, Network = 10, Established = "12-2-2002"},
                            new SeedData { Name = "Faaborg-Midtfyn", Number = 11, Network = 9, Established = "29-2-2000"},
                            new SeedData { Name = "Gedved", Number = 232, Network = 8, Established = "25-6-2009"},
                            new SeedData { Name = "Gentofte", Number = 68, Network = 10, Established = "18-9-2001"},
                            new SeedData { Name = "Give", Number = 45, Network = 8, Established = "29-1-2001"},
                            new SeedData { Name = "Gjesing", Number = 178, Network = 6, Established = "28-3-2006"},
                            new SeedData { Name = "Gladsaxe", Number = 130, Network = 15, Established = "7-10-2003"},
                            new SeedData { Name = "Glamsbjerg", Number = 84, Network = 9, Established = "25-2-2002"},
                            new SeedData { Name = "Glostrup-Hvissinge", Number = 31, Network = 0, Established = "25-10-2000"},
                            new SeedData { Name = "Gram", Number = 166, Network = 7, Established = "3-11-2005"},
                            new SeedData { Name = "Grenå", Number = 195, Network = 4, Established = "16-5-2007"},
                            new SeedData { Name = "Greve", Number = 10, Network = 16, Established = "28-2-2000"},
                            new SeedData { Name = "Grindsted", Number = 17, Network = 6, Established = "6-6-2000"},
                            new SeedData { Name = "Græsted/Gilleleje", Number = 96, Network = 10, Established = "13-6-2002"},
                            new SeedData { Name = "Gråsten (under Åbenrå)", Number = 0, Network = 0, Established = "11-6-2012"},
                            new SeedData { Name = "Gullestrup", Number = 234, Network = 5, Established = "9-12-2009"},
                            new SeedData { Name = "Gørlev", Number = 149, Network = 11, Established = "27-9-2004"},
                            new SeedData { Name = "Haderslev - Syd", Number = 127, Network = 7, Established = "19-6-2007"},
                            new SeedData { Name = "Haderslev", NewName= "Haderslev C", Number = 168, Network = 7, Established = "1-12-2005"},
                            new SeedData { Name = "Hadsund", Number = 26, Network = 2, Established = "12-9-2000"},
                            new SeedData { Name = "Hals", NewName = "Hals-Aalborg", Number = 85, Network = 1, Established = "11-3-2002"},
                            new SeedData { Name = "Halsnæs", Number = 115, Network = 10, Established = "4-2-2003"},
                            new SeedData { Name = "Hammel", Number = 89, Network = 4, Established = "23-4-2002"},
                            new SeedData { Name = "Hedehusene", Number = 180, Network = 15, Established = "27-10-2009"},
                            new SeedData { Name = "Hedensted", Number = 205, Network = 8, Established = "7-5-2008"},
                            new SeedData { Name = "Hedensted - Vest", Number = 116, Network = 8, Established = "27-2-2003"},
                            new SeedData { Name = "Helsinge", Number = 134, Network = 10, Established = "10-12-2003"},
                            new SeedData { Name = "Helsingør", Number = 1, Network = 10, Established = "6-3-1998"},
                            new SeedData { Name = "Herlev", Number = 187, Network = 0, Established = "12-10-2006"},
                            new SeedData { Name = "Herning", Number = 34, Network = 3, Established = "30-10-2000"},
                            new SeedData { Name = "Herredsvang (Aarhus V)", Number = 80, Network = 4, Established = "20-2-2002"},
                            new SeedData { Name = "Hillerød", Number = 124, Network = 10, Established = "10-6-2003"},
                            new SeedData { Name = "Hinnerup", Number = 109, Network = 4, Established = "11-11-2002"},
                            new SeedData { Name = "Hirtshals", Number = 53, Network = 1, Established = "21-3-2001"},
                            new SeedData { Name = "Hjordkær (Aabenraa)", Number = 170, Network = 7, Established = "19-1-2006"},
                            new SeedData { Name = "Hjørring", Number = 57, Network = 1, Established = "9-4-2001"},
                            new SeedData { Name = "Hobro", Number = 120, Network = 2, Established = "10-4-2003"},
                            new SeedData { Name = "Holbæk", Number = 108, Network = 11, Established = "28-10-2002"},
                            new SeedData { Name = "Holmbladsgade", Number = 186, Network = 0, Established = "9-10-2006"},
                            new SeedData { Name = "Holstebro", Number = 4, Network = 5, Established = "20-5-1999"},
                            new SeedData { Name = "Holsted", Number = 209, Network = 6, Established = "18-6-2008"},
                            new SeedData { Name = "Holtbjerg", Number = 144, Network = 5, Established = "20-6-2004"},
                            new SeedData { Name = "Hornbæk (Helsingør)", Number = 139, Network = 10, Established = "31-3-2004"},
                            new SeedData { Name = "Hornslet", Number = 202, Network = 4, Established = "11-3-2008"},
                            new SeedData { Name = "Horsens", Number = 16, Network = 8, Established = "30-5-2000"},
                            new SeedData { Name = "Hovedgaard", Number = 238, Network = 8, Established = "27-1-2010"},
                            new SeedData { Name = "Hundested (Halsnæs)", Number = 188, Network = 11, Established = "?"},
                            new SeedData { Name = "Husum", Number = 246, Network = 14, Established = "1-3-2011"},
                            new SeedData { Name = "Hvide Sande (Holmsland)", Number = 153, Network = 5, Established = "17-11-2004"},
                            new SeedData { Name = "Hvidebæk Kommune", Number = 155, Network = 0, Established = "22-2-2005"},
                            new SeedData { Name = "Hvidovre (tidligere Avedøre)", Number = 95, Network = 0, Established = "6-6-2002"},
                            new SeedData { Name = "Hvidovre Syd", Number = 211, Network = 16, Established = "25-8-2008"},
                            new SeedData { Name = "Høje Gladsaxe (Gammel)", Number = 250, Network = 0, Established = "24-11-2010"},
                            new SeedData { Name = "Høng", Number = 63, Network = 11, Established = "7-8-2001"},
                            new SeedData { Name = "Hørning", Number = 243, Network = 4, Established = "8-3-2010"},
                            new SeedData { Name = "Hørsholm", Number = 240, Network = 10, Established = "16-3-2010"},
                            new SeedData { Name = "Haarby", Number = 87, Network = 9, Established = "6-4-2002"},
                            new SeedData { Name = "Ikast", Number = 138, Network = 5, Established = "25-3-2004"},
                            new SeedData { Name = "Ilulissat", Number = 92, Network = 19, Established = "09-052002"},
                            new SeedData { Name = "Indre Nørrebro", Number = 212, Network = 14, Established = "25-8-2008"},
                            new SeedData { Name = "Ishøj", Number = 47, Network = 16, Established = "15-2-2001"},
                            new SeedData { Name = "Juelsminde", Number = 148, Network = 8, Established = "23-9-2004"},
                            new SeedData { Name = "Jyderup (overgået til Holbæk)", Number = 196, Network = 11, Established = "19-6-2007"},
                            new SeedData { Name = "Jyllinge", Number = 163, Network = 10, Established = "30-6-2005"},
                            new SeedData { Name = "Kalundborg", Number = 62, Network = 11, Established = "7-6-2001"},
                            new SeedData { Name = "Karup", Number = 123, Network = 3, Established = "4-6-2003"},
                            new SeedData { Name = "Kastrup", NewName  = "Tårnby", Number = 219, Network = 14, Established = "18-11-2008"},
                            new SeedData { Name = "Kgs. Enghave", Number = 157, Network = 0, Established = "17-3-2005"},
                            new SeedData { Name = "Kjellerup", Number = 54, Network = 3, Established = "29-3-2001"},
                            new SeedData { Name = "Klaksvig", Number = 190, Network = 18, Established = "14-12-2006"},
                            new SeedData { Name = "Klarup", Number = 225, Network = 2, Established = "4-3-2009"},
                            new SeedData { Name = "Kokkedal", Number = 40, Network = 10, Established = "23-11-2000"},
                            new SeedData { Name = "Kolding", Number = 15, Network = 8, Established = "22-5-2000"},
                            new SeedData { Name = "Korsør", Number = 100, Network = 11, Established = "22-8-2002"},
                            new SeedData { Name = "Kvaglund-Stengårdsvej", Number = 214, Network = 6, Established = "16-9-2008"},
                            new SeedData { Name = "København C (Kritiske Muslimer)", Number = 99, Network = 14, Established = "19-8-2002"},
                            new SeedData { Name = "København City", Number = 204, Network = 14, Established = "2-11-2007"},
                            new SeedData { Name = "Køge", Number = 42, Network = 16, Established = "28-11-2000"},
                            new SeedData { Name = "Langeland", Number = 140, Network = 9, Established = "27-4-2004"},
                            new SeedData { Name = "Langeskov", Number = 197, Network = 9, Established = "8-10-2007"},
                            new SeedData { Name = "Lemvig", Number = 192, Network = 3, Established = "15-3-2007"},
                            new SeedData { Name = "Lunderskov", Number = 66, Network = 8, Established = "6-9-2001"},
                            new SeedData { Name = "Lundtoftegade", Number = 9, Network = 14, Established = "9-2-2000"},
                            new SeedData { Name = "Lyngby", Number = 229, Network = 10, Established = "13-5-2009"},
                            new SeedData { Name = "Løgstør", Number = 8, Network = 1, Established = "23-11-1999"},
                            new SeedData { Name = "Løgumkloster (Tønder)", Number = 161, Network = 7, Established = "2-5-2005"},
                            new SeedData { Name = "Løkken", Number = 101, Network = 1, Established = "5-9-2002"},
                            new SeedData { Name = "Maniitsoq", Number = 249, Network = 19, Established = "20-10-2010"},
                            new SeedData { Name = "Mariager", Number = 24, Network = 4, Established = "7-9-2000"},
                            new SeedData { Name = "Maribo", Number = 119, Network = 13, Established = "7-4-2003"},
                            new SeedData { Name = "MC - Natteravnene", Number = 215, Network = 10, Established = "29-6-2008"},
                            new SeedData { Name = "Middelfart", Number = 7, Network = 9, Established = "27-10-1999"},
                            new SeedData { Name = "Mjølnerparken-Kbh. N", Number = 83, Network = 0, Established = "21-2-2002"},
                            new SeedData { Name = "Munkebo", Number = 141, Network = 9, Established = "11-5-2004"},
                            new SeedData { Name = "Møldrup", Number = 12, Network = 3, Established = "4-5-2000"},
                            new SeedData { Name = "Nakskov", Number = 60, Network = 13, Established = "29-5-2001"},
                            new SeedData { Name = "Nanortalik", Number = 103, Network = 19, Established = "14-9-2002"},
                            new SeedData { Name = "Narsaq", Number = 255, Network = 19, Established = "12-11-2011"},
                            new SeedData { Name = "Nexø", Number = 46, Network = 17, Established = "13-2-2001"},
                            new SeedData { Name = "Nibe", Number = 51, Network = 2, Established = "19-3-2001"},
                            new SeedData { Name = "Nordals", Number = 41, Network = 7, Established = "23-11-2000"},
                            new SeedData { Name = "Nr. Rangstrup", Number = 150, Network = 7, Established = "27-10-2004"},
                            new SeedData { Name = "Nuuk", Number = 25, Network = 19, Established = "7-9-2000"},
                            new SeedData { Name = "Nykøbing Falster", Number = 61, Network = 13, Established = "6-6-2001"},
                            new SeedData { Name = "Nykøbing Falster", Number = 247, Network = 13, Established = "5-7-2010"},
                            new SeedData { Name = "Nykøbing Mors", Number = 133, Network = 3, Established = "7-10-2003"},
                            new SeedData { Name = "Næstved", Number = 3, Network = 13, Established = "23-4-1999"},
                            new SeedData { Name = "Nørager (Bero marts  2013)", Number = 110, Network = 2, Established = "14-11-2002"},
                            new SeedData { Name = "Odden (Odsherred)", Number = 145, Network = 11, Established = "30-6-2004"},
                            new SeedData { Name = "Odense", Number = 259, Network = 9, Established = "15-2-2012"},
                            new SeedData { Name = "Odsherred", Number = 97, Network = 11, Established = "17-6-2002"},
                            new SeedData { Name = "Otterup", Number = 49, Network = 9, Established = "27-2-2001"},
                            new SeedData { Name = "Padborg (Aabenraa)", Number = 128, Network = 7, Established = "9-9-2003"},
                            new SeedData { Name = "Pal Familie Natteravne ", Number = 237, Network = 0, Established = "?"},
                            new SeedData { Name = "Pandrup", Number = 77, Network = 1, Established = "22-11-2001"},
                            new SeedData { Name = "Præstø", Number = 86, Network = 0, Established = "18-3-2002"},
                            new SeedData { Name = "Paamiut", Number = 254, Network = 19, Established = "31-3-2011"},
                            new SeedData { Name = "Qaqortog", Number = 201, Network = 19, Established = "20-2-2008"},
                            new SeedData { Name = "Qasigiannguit", Number = 0, Network = 19, Established = "16-9-2004"},
                            new SeedData { Name = "Qasigiannguit", Number = 147, Network = 19, Established = "16-9-2004"},
                            new SeedData { Name = "Qaanaaq", Number = 262, Network = 19, Established = "24-5-2012"},
                            new SeedData { Name = "Ramløse (Helsinge)", Number = 252, Network = 10, Established = "0-1-1900"},
                            new SeedData { Name = "Randers", Number = 2, Network = 4, Established = "25-9-1998"},
                            new SeedData { Name = "Ribe", Number = 67, Network = 6, Established = "17-9-2001"},
                            new SeedData { Name = "Ringkøbing & Søndervig", NewName = "Ringkøbing", Number = 142, Network = 5, Established = "17-8-2004"},
                            new SeedData { Name = "Ringsted", Number = 73, Network = 11, Established = "9-10-2001"},
                            new SeedData { Name = "Roskilde/Viby",  NewName = "Roskilde", Number = 52, Network = 10, Established = "21-3-2001"},
                            new SeedData { Name = "Rudersdal", Number = 231, Network = 10, Established = "17-6-2009"},
                            new SeedData { Name = "Ruds Vedby", Number = 263, Network = 11, Established = "24-10-2012"},
                            new SeedData { Name = "Ry", Number = 182, Network = 4, Established = "18-5-2006"},
                            new SeedData { Name = "Røde Kro (Aabenraa)", Number = 171, Network = 7, Established = "0-1-1900"},
                            new SeedData { Name = "Rødovre", Number = 227, Network = 15, Established = "30-3-2009"},
                            new SeedData { Name = "Rønde", Number = 122, Network = 4, Established = "26-5-2003"},
                            new SeedData { Name = "Rønne", Number = 5, Network = 17, Established = "11-6-1999"},
                            new SeedData { Name = "Samsø", Number = 228, Network = 4, Established = "3-6-2009"},
                            new SeedData { Name = "Seest (Kolding)", Number = 233, Network = 8, Established = "0-1-1900"},
                            new SeedData { Name = "Silkeborg", Number = 56, Network = 3, Established = "20-6-2004"},
                            new SeedData { Name = "Sindal", Number = 36, Network = 1, Established = "1-11-2000"},
                            new SeedData { Name = "Sisimiut (tidligere)", Number = 22, Network = 19, Established = "25-8-2000"},
                            new SeedData { Name = "Sisimiut", Number = 268, Network = 19, Established = "18-1-2014"},
                            new SeedData { Name = "Sjælør", Number = 104, Network = 14, Established = "17-9-2002"},
                            new SeedData { Name = "Skagen (Frederikshavn)", Number = 32, Network = 1, Established = "26-10-2000"},
                            new SeedData { Name = "Skanderborg", Number = 206, Network = 4, Established = "13-5-2008"},
                            new SeedData { Name = "Skive", Number = 93, Network = 3, Established = "14-5-2002"},
                            new SeedData { Name = "Skjern-Egvad", Number = 132, Network = 5, Established = "28-10-2003"},
                            new SeedData { Name = "Skovlunde", Number = 106, Network = 15, Established = "18-9-2002"},
                            new SeedData { Name = "Skovparken (Kolding)", Number = 154, Network = 8, Established = "5-1-2005"},
                            new SeedData { Name = "Skælskør", Number = 125, Network = 11, Established = "16-6-2003"},
                            new SeedData { Name = "Skærbæk", Number = 177, Network = 7, Established = "14-3-2006"},
                            new SeedData { Name = "Skævinge", Number = 152, Network = 10, Established = "8-11-2004"},
                            new SeedData { Name = "Skørping-Terndrup", Number = 13, Network = 2, Established = "8-6-2000"},
                            new SeedData { Name = "Slagelse", Number = 29, Network = 11, Established = "16-10-2000"},
                            new SeedData { Name = "Slangerup", Number = 137, Network = 10, Established = "24-3-2004"},
                            new SeedData { Name = "Smidstrup-Skærup", Number = 208, Network = 8, Established = "21-5-2008"},
                            new SeedData { Name = "Smørum", Number = 185, Network = 10, Established = "29-6-2006"},
                            new SeedData { Name = "Solrød", Number = 164, Network = 16, Established = "19-9-2005"},
                            new SeedData { Name = "Sorø", Number = 242, Network = 11, Established = "26-4-2010"},
                            new SeedData { Name = "St.Heddinge", Number = 126, Network = 13, Established = "17-6-2003"},
                            new SeedData { Name = "Stege", Number = 35, Network = 13, Established = "31-10-2000"},
                            new SeedData { Name = "Stenløse", Number = 14, Network = 10, Established = "15-5-2000"},
                            new SeedData { Name = "Struer", Number = 64, Network = 3, Established = "16-8-2001"},
                            new SeedData { Name = "Støvring", Number = 88, Network = 2, Established = "10-4-2002"},
                            new SeedData { Name = "Suðuroy", Number = 256, Network = 18, Established = "19-11-2011"},
                            new SeedData { Name = "Sundbyvester", Number = 224, Network = 14, Established = "21-2-2009"},
                            new SeedData { Name = "Glumsø", NewName = "Suså-Glumsø", Number = 38, Network = 13, Established = "14-11-2000"},
                            new SeedData { Name = "Svendborg", NewName = "Svendborg - Ærø", Number = 69, Network = 9, Established = "20-9-2001"},
                            new SeedData { Name = "Svogerslev (Roskilde)", Number = 98, Network = 10, Established = "18-6-2002"},
                            new SeedData { Name = "Sæby", Number = 158, Network = 1, Established = "14-4-2005"},
                            new SeedData { Name = "Sønderborg", Number = 30, Network = 7, Established = "24-10-2000"},
                            new SeedData { Name = "Sønderris", Number = 82, Network = 6, Established = "21-2-2002"},
                            new SeedData { Name = "Tasiilaq", Number = 253, Network = 19, Established = "31-3-2011"},
                            new SeedData { Name = "Thisted", Number = 131, Network = 3, Established = "20-10-2003"},
                            new SeedData { Name = "Thyregod", Number = 230, Network = 8, Established = "13-5-2009"},
                            new SeedData { Name = "Tilst", Number = 21, Network = 4, Established = "17-8-2000"},
                            new SeedData { Name = "Tingbjerg (Husum)", Number = 236, Network = 0, Established = "11-1-2010"},
                            new SeedData { Name = "Tistrup (Ølgod)", Number = 198, Network = 6, Established = "0-1-1900"},
                            new SeedData { Name = "Tommerup", Number = 222, Network = 9, Established = "2-12-2008"},
                            new SeedData { Name = "Tórshavn", Number = 75, Network = 18, Established = "14-11-2001"},
                            new SeedData { Name = "Trige", Number = 160, Network = 4, Established = "28-4-2005"},
                            new SeedData { Name = "Tune (Greve)", Number = 146, Network = 16, Established = "0-1-1900"},
                            new SeedData { Name = "Tønder", Number = 181, Network = 7, Established = "9-5-2006"},
                            new SeedData { Name = "Taastrup", Number = 55, Network = 0, Established = "2-4-2001"},
                            new SeedData { Name = "Tåstrup (Gadehavegård)", Number = 112, Network = 15, Established = "07 03 2012"},
                            new SeedData { Name = "Ullerslev", Number = 102, Network = 9, Established = "12-9-2002"},
                            new SeedData { Name = "Urbanplanen", Number = 1, Network = 14, Established = "14-6-2005"},
                            new SeedData { Name = "Uummannaq", Number = 59, Network = 19, Established = "20-4-2001"},
                            new SeedData { Name = "Uummannaq", Number = 258, Network = 19, Established = "10-1-2012"},
                            new SeedData { Name = "Vagum", Number = 218, Network = 18, Established = "1-11-2008"},
                            new SeedData { Name = "Valby Centrum", NewName= "Valby", Number = 203, Network = 14, Established = "1-4-2008"},
                            new SeedData { Name = "Vallensbæk", Number = 20, Network = 16, Established = "14-6-2000"},
                            new SeedData { Name = "Vamdrup", Number = 28, Network = 8, Established = "2-10-2000"},
                            new SeedData { Name = "Vanløse", Number = 260, Network = 14, Established = "8-3-2012"},
                            new SeedData { Name = "Varde", Number = 33, Network = 6, Established = "30-10-2000"},
                            new SeedData { Name = "Vejen", Number = 50, Network = 6, Established = "19-3-2001"},
                            new SeedData { Name = "Vejle", Number = 241, Network = 8, Established = "21-4-2010"},
                            new SeedData { Name = "Vejle-C", Number = 105, Network = 8, Established = "17-9-2002"},
                            new SeedData { Name = "Vejle-Nord", Number = 90, Network = 8, Established = "2-5-2002"},
                            new SeedData { Name = "Vejle-Syd", Number = 91, Network = 8, Established = "2-5-2002"},
                            new SeedData { Name = "Vemmelev", Number = 213, Network = 11, Established = "3-9-2008"},
                            new SeedData { Name = "Viborg", Number = 107, Network = 3, Established = "1-12-2008"},
                            new SeedData { Name = "Viby Sjælland (Roskilde)", Number = 245, Network = 10, Established = "21-6-2010"},
                            new SeedData { Name = "Videbæk", Number = 183, Network = 5, Established = "7-6-2006"},
                            new SeedData { Name = "Vojens", Number = 79, Network = 7, Established = "5-2-2002"},
                            new SeedData { Name = "Vordingborg", Number = 39, Network = 13, Established = "20-11-2000"},
                            new SeedData { Name = "Ældre Sagens Natteravne", Number = 239, Network = 4, Established = "29-10-2010"},
                            new SeedData { Name = "Ældre Sagens Natteravne", Number = 0, Network = 0, Established = "0-1-1900"},
                            new SeedData { Name = "Ærø (Svendborg -  Ærø)", Number = 261, Network = 9, Established = "7-4-2012"},
                            new SeedData { Name = "Ølgod", Number = 111, Network = 6, Established = "21-11-2002"},
                            new SeedData { Name = "Ølsemagle/Ølby", Number = 129, Network = 0, Established = "6-10-2003"},
                            new SeedData { Name = "Ørbæk", Number = 169, Network = 9, Established = "5-12-2005"},
                            new SeedData { Name = "Ragnhildgade", NewName= "Østerbro", Number = 71, Network = 14, Established = "10-10-2001"},
                            new SeedData { Name = "AAB58/Nørrebro", Number = 257, Network = 0, Established = "14 11 2011"},
                            new SeedData { Name = "AAB58/Nørrebro", Number = 257, Network = 14, Established = "14-11-2011"},
                            new SeedData { Name = "Aabenraa", Number = 117, Network = 7, Established = "13-3-2003"},
                            new SeedData { Name = "Aakirkeby (Nexø)", Number = 165, Network = 17, Established = "29-9-2005"},
                            new SeedData { Name = "Aalborg C (slået sam<men med Hals marts 14)", Number = 235, Network = 1, Established = "7-12-2009"},
                            new SeedData { Name = "Aalborg Ø", Number = 223, Network = 2, Established = "19-1-2009"},
                            new SeedData { Name = "Aalestrup", Number = 173, Network = 2, Established = "30-1-2006"},
                            new SeedData { Name = "Ålholm", Number = 172, Network = 1, Established = "30-1-2006"},
                            new SeedData { Name = "Århus Nord", NewName = "Århus N", Number = 244, Network = 4, Established = "22-6-2010"},
                            new SeedData { Name = "Århus V ", Number = 193, Network = 4, Established = "24-4-2007"},
                            new SeedData { Name = "Års", Number = 78, Network = 2, Established = "4-12-2001"}

        
        };

            Dictionary<string, DateTime> PersonCreated = new Dictionary<string, DateTime>();
            Dictionary<string, Guid> PersonGuid = new Dictionary<string, Guid>();


            #endregion


            using (var context = new Repository())
            {
                StringBuilder SQLIdentity = new StringBuilder();
                Association ass = ExtractAssociation(id);
                System.Diagnostics.Debug.WriteLine("Start migrating Association: \"" + ass.Name + "\"");




                DateTime Created = ass.Created;




                SeedData rec = Seed.Find(n => n.Name.ToLower() == ass.Name.ToLower());
                if (rec != null)
                {
                    ass.Network = context.Networks.Where(n => n.NetworkNumber == rec.Network).FirstOrDefault();
                    ass.Established = rec.EstablishedDT;
                    if (!String.IsNullOrWhiteSpace(rec.NewName)) ass.Name = rec.NewName;
                    ass.Number = rec.Number;
                    ass.Governance = rec.Governance;
                }

                foreach (NRMembership m in ass.Memberships)
                {
                    PersonCreated.Add(m.Person.UserName, m.Person.Created);
                    PersonGuid.Add(m.Person.UserName, m.Person.PersonID);
                    var tmpPerson = new Person
                    {
                        UserName = m.Person.UserName,
                        FirstName = "Test",
                        FamilyName = "Test",
                        Address = "Test",
                        City = "Test",
                        Zip = "Test"
                    };
                    context.Entry(tmpPerson).State = EntityState.Added;

                    context.SaveChanges();

                    StringBuilder SQLIdentityPerson = new StringBuilder();
                    Created = (DateTime)PersonCreated[m.Person.UserName.ToString()];
                    Guid Gid = (Guid)PersonGuid[m.Person.UserName.ToString()];
                    SQLIdentityPerson.AppendLine(string.Format("UPDATE [People] SET Created = '{0}' WHERE Username = '******';", Created.ToString("yyyy-MM-dd hh:mm:ss.mmm"), m.Person.UserName.ToString()));
                    SQLIdentityPerson.AppendLine(string.Format("UPDATE [People] SET PersonID = '{0}' WHERE Username = '******';", Gid.ToString(), m.Person.UserName.ToString()));
                    context.Database.ExecuteSqlCommand(SQLIdentityPerson.ToString());

                    if (rec != null)
                    {
                        if (m.Person.UserName == rec.Chairmann)
                        { m.BoardFunction = BoardFunctionType.Chairman; }
                        else if (m.Person.UserName == rec.Accountant)
                        { m.BoardFunction = BoardFunctionType.Accountant; }
                        else if (m.Person.UserName == rec.Auditor)
                        { m.BoardFunction = BoardFunctionType.Auditor; }
                        else if (m.Person.UserName == rec.AuditorAlternate)
                        { m.BoardFunction = BoardFunctionType.AuditorAlternate; }
                        else if (rec.BoardMembers != null && rec.BoardMembers.Contains(m.Person.UserName))
                        { m.BoardFunction = BoardFunctionType.BoardMember; }
                        else if (rec.Alternate != null && rec.Alternate.Contains(m.Person.UserName))
                        { m.BoardFunction = BoardFunctionType.Alternate; }
                    }

                    context.Entry(m.Person).State = EntityState.Modified;
                    System.Diagnostics.Debug.WriteLine("  - ("+ ass.Name + ") ["+ m.Person.FullName + "]");

                    context.SaveChanges();

                    if (!m.Absent) //&& !WebSecurity.UserExists(m.Person.UserName))
                    {
                        WebSecurity.CreateAccount(m.Person.UserName, m.Person.Password);
                        if (WebSecurity.ConfirmAccount(m.Person.UserName))
                        {
                            System.Diagnostics.Debug.WriteLine("**Migrating Person: \"" + m.Person.UserName + "\" / (" + m.Person.Password + ")");
                        }
                    }

                }

                System.Diagnostics.Debug.WriteLine("  - Saving (" + ass.Name + ")");
                context.Entry(ass).State = EntityState.Added;

                context.SaveChanges();

                context.Memberships.Where(m => m.Association.AssociationID == ass.AssociationID)
                    .ToList()
                    .ForEach(p => p.Person.CurrentAssociation = p.Association.AssociationID);
                context.SaveChanges();


                //SQLIdentity.AppendLine("SET IDENTITY_INSERT [Associations] ON;");
                SQLIdentity.AppendLine(string.Format("UPDATE [Associations] SET Created = '{0}' WHERE AssociationID = '{1}';", Created.ToString("yyyy-MM-dd hh:mm:ss.mmm"), ass.AssociationID.ToString()));
                //SQLIdentity.AppendLine("SET IDENTITY_INSERT [Associations] OFF;");


                context.Database.ExecuteSqlCommand(SQLIdentity.ToString());



            }

        }
Пример #10
0
        /// <summary>
        /// Modifies an Profile image.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="w">The w.</param>
        /// <param name="h">The h.</param>
        /// <param name="PersonID">Profile Image to work on</param>
        /// <returns>New Image Id</returns>
        private bool ModifyImage(int x, int y, int w, int h, Person person)
        {
            string ProfilDirSetting = ConfigurationManager.AppSettings["ProfileImage"];

            if (string.IsNullOrWhiteSpace(ProfilDirSetting)) { throw new ArgumentNullException(); }

            var ProfilBilled = string.Format(ProfilDirSetting, person.PersonID);

            if (System.IO.File.Exists(Server.MapPath(ProfilBilled)))
            {
                Image img = Image.FromFile(Server.MapPath(ProfilBilled));



                using (System.Drawing.Bitmap _bitmap = new System.Drawing.Bitmap(428, 550))
                {
                    _bitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
                    using (Graphics _graphic = Graphics.FromImage(_bitmap))
                    {
                        _graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        _graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        _graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                        _graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                        _graphic.Clear(Color.White);
                        //_graphic.DrawImage(img, 0, 0, w, h);
                        _graphic.DrawImage(img, new Rectangle(0, 0, 428, 550), x, y, w, h, GraphicsUnit.Pixel);
                        //_graphic.DrawImage(img, new Rectangle(0, 0, w, h), x, y, w, h, GraphicsUnit.Pixel);
                        //_graphic.DrawImage(img, 0, 0, img.Width, img.Height);
                        //_graphic.DrawImage(img, new Rectangle(0, 0, 428, 550), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel);

                    }
                    System.Drawing.Imaging.PropertyItem prop = img.PropertyItems[0];
                    SetProperty(ref prop, 270, string.Format("Username: {0}, {1}", person.UserName, person.FullName));
                    _bitmap.SetPropertyItem(prop);
                    SetProperty(ref prop, 33432, "Copyright Natteravnene www.natteravnene.dk");
                    _bitmap.SetPropertyItem(prop);
                    //TODO: Set more properties
                    img.Dispose();

                    _bitmap.Save(Server.MapPath(ProfilBilled), System.Drawing.Imaging.ImageFormat.Jpeg);
                }

            }

            return true;
        }
Пример #11
0
        public ActionResult Edit(Person person, string RadioGender, string Action, Guid Attach)
        {
            Person CU = new Person();
            if (person.PersonID != Guid.Empty)
            {
                CU = reposetory.GetPersonComplete(person.PersonID);
                if (CU == null) return RedirectToAction("Index");
            }

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

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

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

            List<AssociationListModel> tmp = reposetory.GetAssociationList(); //.RemoveAll(item => CU.Memberships.ToList().Exists(p => p.Association.AssociationID == item.AssociationID));
            ViewBag.Attach = new SelectList(tmp, "AssociationID", "Name");

            if (Action == "add" && Attach != Guid.Empty)
            {
                Association association = reposetory.GetAssociation(Attach);
                if (association != null && association.Status == AssociationStatus.Active)
                {
                    NR.Models.NRMembership Mem = new NR.Models.NRMembership
                    {
                        Association = association,
                        SignupDate = DateTime.Now,
                        Type = PersonType.Active
                    };
                    CU.Memberships.Add(Mem);
                    reposetory.SavePerson(CU);
                    ModelState.Clear();
                }

            }


            if (Action == "Edit" & ModelState.IsValid)
            {
                var refresh = person.PersonID == Guid.Empty;
                reposetory.SavePerson(CU);
                if (refresh)
                {
                    //WebSecurity.IsConfirmed 
                    if (!WebSecurity.IsConfirmed(CU.UserName)) WebSecurity.CreateAccount(CU.UserName, CU.Password);
                    if (!string.IsNullOrWhiteSpace(CU.Email))
                    {
                        var mail = new WelcomeMailEmail
                        {
                            To = CU.Email,
                            UserName = CU.UserName,
                            Password = CU.Password
                        };
                        mail.Send();
                    }
                }
                ViewBag.FormSucces = true;
                ModelState.Clear();
            }
            if (CU.Memberships == null) CU.Memberships = new List<NR.Models.NRMembership>();

            if (CU.Causes == null) CU.Causes = new List<CausePartisipant>();
            return View(CU);
        }
Пример #12
0
        public ActionResult Setup(Person CU)
        {
            Person dbPerson = reposetory.GetPersonComplete(CurrentProfile.PersonID);
            if (CU == null | dbPerson.PersonID != CurrentProfile.PersonID) return HttpNotFound();
 
            dbPerson.ListLines = CU.ListLines < 10 ? 10 : CU.ListLines;
            if (dbPerson.CurrentAssociation != CU.CurrentAssociation) dbPerson.CurrentAssociation = CU.CurrentAssociation; 

            reposetory.SavePerson(dbPerson);
            CurrentProfile.Clear();
            ModelState.Clear();
            ViewBag.FormSucces = true;

            var Associations = dbPerson.Memberships.Select(d => new SelectListItem { Value = d.AssociationID.ToString(), Text = d.Association.Name }).ToList();
            if (Associations == null)
            {
                Associations = new List<SelectListItem>();
                Associations.Insert(0, new SelectListItem { Value = Guid.Empty.ToString(), Text = General.DropDownEmpty });
            }
            if (Associations != null)
            {
                ViewBag.Associations = Associations;
            }
            return View(CU);
        }
Пример #13
0
        public ActionResult EditProfile(Person person, string RadioGender, string Action)
        {
            Person CU = new Person();
            if (person.PersonID != Guid.Empty)
            {
                CU = reposetory.GetPersonComplete(person.PersonID);
                if (CU == null) return HttpNotFound();
            }

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

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



            if (ModelState.IsValid)
            {
                var refresh = person.PersonID == Guid.Empty;
                reposetory.SavePerson(CU);
                ViewBag.FormSucces = true;
                CurrentProfile.Clear();
                //if (refresh) return RedirectToAction("Edit", new { ID = CU.PersonID.ToString() });
            }
            //if (CU.Memberships == null) CU.Memberships = new List<NRMembership>();


            return View(CU);
        }
Пример #14
0
 private string PhoneNumberBuild(Person Person)
 {
     if (Person.Mobile.StartsWith("+")) return Person.Mobile.PhoneTrim(); //Person.Mobile.Remove(0,1).PhoneTrim();
     if (Person.Country == 0 ) return "+45" + Person.Mobile.PhoneTrim();
     return "+" + ((int)Person.Country).ToString() + Person.Mobile.PhoneTrim();
 }
Пример #15
0
 public static string ReplaceTagPerson(this string value, Person currentPerson)
 {
     if (string.IsNullOrWhiteSpace(value)) return value;
     return value.Replace(Firstname, currentPerson.FirstName).Replace(LastName, currentPerson.FamilyName).Replace(Email, currentPerson.Email).Replace(Mobile, currentPerson.Mobile);
 }
Пример #16
0
        public ActionResult _TestText(string Mobile)
        {
            if (!string.IsNullOrWhiteSpace(Mobile))
            {
                Person person = new Person
                {
                    Mobile = Mobile,
                    Country = Country.DK
                };

                ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(null, null, null);
                SMSGateway.FromText = General.SystemTextMessagesFrom;
                SMSGateway.Message = "Test text";
                SMSGateway.Recipient = new List<Person> { person };
                //reposetory.NewTextMessage(SMSGateway, association.AssociationID);

                //if (HandshakeUrl != null && HandshakeUrl.Contains("##")) SMSGateway.HandShakeUrl = HandshakeUrl.Replace("##", SMSGateway.TextId);

                try
                {
                    if (SMSGateway.Send())
                    {

                    };
                }
                catch (Exception ex)
                {
                    return Content(ex.ToString());
                }

            }
            return new HttpStatusCodeResult(HttpStatusCode.NoContent);
        }
Пример #17
0
        public ActionResult Edit(Guid? ID)
        {
            Person CU;
            if (ID == null)
            {
                CU = new Person
                    {
                        Country = Country.DK,
                        Memberships = new List<NRMembership>(),
                        Causes = new List<CausePartisipant>()
                    };
            }
            else
            {
                CU = reposetory.GetPersonComplete((Guid)ID);
                if (CU == null) return RedirectToAction("Index");
            }
            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(CU);
        }