Example #1
1
        private void PopulateDatabase()
        {
            Hobby hobby = new Hobby {
                Name = "Basketball",
                Blurb = "Watching and playing Hoops!",
                Description = "I like to watch Basketball.  " +
                    "I mostly follow NBA games and teams.  " +
                    "Although I haven't played in a long time, " +
                    "I like to when I find the time.",
                Image = "basketball.png",
                ID = 0
            };
            App.Database.SaveHobby (hobby);
            HobbyList.Add (hobby);

            hobby = new Hobby {
                Name = "Technology",
                Blurb = "Following and exploring new techology.",
                Description = "I like to spend time reading articles " +
                    "about new technologies.  I'm particulary interested " +
                    "in mobile devices and advancements in automotives.",
                Image = "tech.png",
                ID = 0
            };
            App.Database.SaveHobby (hobby);
            HobbyList.Add (hobby);

            hobby = new Hobby {
                Name = "DIY",
                Blurb = "Do it Yourself.",
                Description = "I like to spend time reading articles " +
                    "about DYI.  I especially like to read about do it " +
                    "yourself car audio projects.",
                Image = "diy_icon.png",
                ID = 0
            };
            App.Database.SaveHobby (hobby);
            HobbyList.Add (hobby);

            hobby = new Hobby {
                Name = "Working Out",
                Blurb = "Going to the gymn and staying in shape.",
                Description = "With the demands of work and life I " +
                    "I try to stay in shape by going to the gymn " +
                    " after work.  I find it is a good way to undwind.",
                Image = "dumbell.png",
                ID = 0
            };
            App.Database.SaveHobby (hobby);
            HobbyList.Add (hobby);
        }
 public HobbyDetailPage(Hobby hobby)
 {
     InitializeComponent ();
     if(hobby != null){
         _hobby = hobby;
     } else {
         _hobby = new Hobby {
             Name = "N/A",
             Description = "N/A",
             Blurb = "N/A"
         };
     }
     BindingContext = _hobby;
 }
Example #3
0
 public static Db.Hobby ToEntity(Hobby hobby)
 {
     return hobby == null ? null : 
         new Db.Hobby
         {
             HobbyId = hobby.HobbyId,
             HobbyName = hobby.HobbyName,
             UserId = hobby.UserId,
             CreatedBy = hobby.CreatedBy,
             CreatedDate = hobby.CreatedDate,
             ModifiedBy = hobby.ModifiedBy,
             ModifiedDate = hobby.ModifiedDate
         };
 }
Example #4
0
 public Chosen(int id, string guestName, Hobby hobby)
 {
     Id        = id;
     GuestName = guestName;
     Hobby     = hobby;
 }
Example #5
0
        public IActionResult Update([FromBody] Hobby entity)
        {
            _repository.Update(entity);

            return(Ok());
        }
Example #6
0
        internal static Hobby AddHobby(Hobby hobby)
        {
            DBManager manager = new DBManager();

            return(manager.AddHobby(hobby));
        }
Example #7
0
 public void Remove(Hobby HobbiesIn) =>
 _Hobbies.DeleteOne(Hobby => Hobby.Id == HobbiesIn.Id);
Example #8
0
 public Guest(System.String name, Sex sex, Hobby hobby)
 {
     this.name = name;
     this.sex = sex;
     this.hobby = hobby;
 }
Example #9
0
    private void PopulateMemberVariables()
    {

        //if(ViewingMember.AccountType == (int)AccountType.Personal)
        if (ViewingMember.AccountType == 0)
        {
            AboutTitle = "About me";

            Field1Title = "My Life";
            Field2Title = "Music";
            Field3Title = "Books";
            Field4Title = "Movies";
            Field5Title = "";
            Field6Title = "";

            MyLife = HTMLUtility.AutoLink(ViewingMember.MemberProfile[0].MyLife.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Gender = GetGender(ViewingMember.Gender);
            LastActive = TimeDistance.TimeAgo(ViewingMember.LastOnline);
            ProfileViews = ViewingMember.MemberProfile[0].NumberOfViews.ToString();

            Hometown = HTMLUtility.AutoLink(ViewingMember.MemberProfile[0].HomeTown);
            Country = HTMLUtility.AutoLink(ViewingMember.CountryName);
            Nick = ViewingMember.NickName;
            DirectUrl = WebRoot + "users/" + ViewingMember.NickName;
            DirectUrlText = WebRoot + "users/" + ViewingMember.NickName;

            Movies = HTMLUtility.AutoLink(ViewingMember.MemberProfile[0].Movies.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Books = HTMLUtility.AutoLink(ViewingMember.MemberProfile[0].Books.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Music = HTMLUtility.AutoLink(ViewingMember.MemberProfile[0].Music.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));

            MemberSince = ViewingMember.CreatedDT.ToString("dd MMMM yyyy");
            RelationshipStatus = GetRelationShipStatus(ViewingMember.MemberProfile[0].RelationshipStatus);

            if (ViewingMember.MemberProfile[0].OtherHalfID != -1)
            {
                // Married
                if (ViewingMember.MemberProfile[0].RelationshipStatus == 2)
                {
                    RelationshipStatus += " To";
                }
                //Kinda have a thing
                else if (ViewingMember.MemberProfile[0].RelationshipStatus == 6)
                {
                    RelationshipStatus += " With";
                }
            }

            OtherHalf = GetOtherHalf(ViewingMember.MemberProfile[0].OtherHalfID);

            BlogFeedURL = QualifyURL(ViewingMember.MemberProfile[0].BlogFeedURL);
            BlogFeedURLText = BreakText(BlogFeedURL);

            BlogURL = QualifyURL(ViewingMember.MemberProfile[0].BlogURL);
            BlogURLText = BreakText(BlogURL);

            MySpaceURL = QualifyURL(ViewingMember.MemberProfile[0].MySpaceURL);
            MySpaceURLText = BreakText(MySpaceURL);

            FaceBookURL = QualifyURL(ViewingMember.MemberProfile[0].FaceBookURL);
            FaceBookURLText = BreakText(FaceBookURL);

            try
            {
                DayJobID = ViewingMember.MemberProfile[0].DayProfessionID;
                NightJobID = ViewingMember.MemberProfile[0].NightProfessionID;
                HobbyID = ViewingMember.MemberProfile[0].HobbyID;

                if (DayJobID != -1)
                {
                    DayJob = new Profession(DayJobID).Name;
                }

                if (NightJobID != -1)
                {
                    NightJob = new Profession(NightJobID).Name;
                }

                if (HobbyID != -1)
                {
                    Hobby = new Hobby(HobbyID).Name;
                }
            }
            catch { }


        }
        //else if(ViewingMember.AccountType == (int)AccountType.Business)
        else if (ViewingMember.AccountType == 1)
        {
           
            Business business = ViewingMember.Business[0];

            AboutTitle = "About us";

            Field1Title = "Our Company";
            Field2Title = "Our Products / Services";
            Field3Title = "What we offer";
            Field4Title = "Where you can find us";
            Field5Title = "What sets us apart";
            Field6Title = "";

            MyLife = HTMLUtility.AutoLink(business.OurCompany.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Music = HTMLUtility.AutoLink(business.BusinessDescription1.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Books = HTMLUtility.AutoLink(business.BusinessDescription2.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));
            Movies = HTMLUtility.AutoLink(business.BusinessDescription3.Replace("\r\n", "<br/>").Replace("\r", "<br/>").Replace("\n", "<br/>"));

            Nick = ViewingMember.NickName;
            DirectUrl = WebRoot + "users/" + ViewingMember.NickName;
            DirectUrlText = WebRoot + "users/" + ViewingMember.NickName;

            MemberSince = ViewingMember.CreatedDT.ToString("dd MMMM yyyy");

            BasicInfo=HTMLUtility.AutoLink(business.BasicInfo);
            CompanyName = HTMLUtility.AutoLink(business.CompanyName);
            CompanyWebsite=HTMLUtility.AutoLink(business.CompanyWebsite);
            CompanyTagLine=HTMLUtility.AutoLink(business.TagLine);
            ContactFirst=HTMLUtility.AutoLink(business.ContactFirst);
            ContactLast=HTMLUtility.AutoLink(business.ContactLast);
            IndustrySector=HTMLUtility.AutoLink(business.IndustrySector);
            YearFounded=business.YearFounded;
            CompanySize=HTMLUtility.AutoLink(business.CompanySize);
            CompanyStreetAddress=HTMLUtility.AutoLink(business.StreetAddress);
            CompanyState=HTMLUtility.AutoLink(business.State);
            CompanyCity=HTMLUtility.AutoLink(business.City);

           
            CompanyCountry = HTMLUtility.AutoLink((new ISOCountry(ViewingMember.ISOCountry)).CountryText);
       


            CompanyZipCode=HTMLUtility.AutoLink(business.ZipCode);

            

            BlogFeedURL = QualifyURL(business.BlogFeedURL);
            BlogFeedURLText = BreakText(BlogFeedURL);

            BlogURL = QualifyURL(business.BlogURL);
            BlogURLText = BreakText(BlogURL);

            MySpaceURL = QualifyURL(business.MySpaceURL);
            MySpaceURLText = BreakText(MySpaceURL);

            FaceBookURL = QualifyURL(business.FaceBookURL);
            FaceBookURLText = BreakText(FaceBookURL);

        }


    }
Example #10
0
 /// <summary>
 /// Method to add hobby to the hobby collection
 /// </summary>
 /// <param name="hobby">Hobby object to be added</param>
 public void Add(Hobby hobby)
 {
     List.Add(hobby);
 }
Example #11
0
 public Chosen(int id, System.String guestName, Hobby hobby)
 {
     this.id = id;
     this.guestName = guestName;
     this.hobby = hobby;
 }
Example #12
0
        public void SavesV2CardWithoutErrors()
        {
            string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string filePath       = Path.Combine(assemblyFolder, "newv2.vcf");

            Assert.IsNotNull(vcard);
            Assert.DoesNotThrow(delegate
            {
                vcard.GivenName  = "Forrest";
                vcard.FamilyName = "Gump";
                PhoneNumber num1 = new PhoneNumber();
                num1.Number      = "(111) 555-1212";
                num1.Type        = PhoneNumberType.None;
                vcard.PhoneNumbers.Add(num1);
                PhoneNumber num2 = new PhoneNumber();
                num2.Number      = "(404) 555-1212";
                num2.Type        = PhoneNumberType.Home;
                vcard.PhoneNumbers.Add(num2);
                PhoneNumber num3 = new PhoneNumber();
                num3.Number      = "(404) 555-1212";
                num3.Type        = PhoneNumberType.MainNumber;
                vcard.PhoneNumbers.Add(num3);
                EmailAddress email1 = new EmailAddress();
                email1.Email        = new System.Net.Mail.MailAddress("*****@*****.**");
                email1.Type         = EmailType.None;
                vcard.EmailAddresses.Add(email1);
                EmailAddress email2 = new EmailAddress();
                email2.Email        = new System.Net.Mail.MailAddress("*****@*****.**");
                email2.Type         = EmailType.Internet;
                vcard.EmailAddresses.Add(email2);
                Address address1  = new Address();
                address1.Location = "Sabo, Yaba";
                address1.Type     = AddressType.None;
                vcard.Addresses.Add(address1);
                Address address2  = new Address();
                address2.Location = "Sabo, Yaba";
                address2.Type     = AddressType.Work;
                vcard.Addresses.Add(address2);
                Photo photo1    = new Photo();
                photo1.Encoding = PhotoEncoding.JPEG;
                photo1.PhotoURL = "www.google/images";
                photo1.Type     = PhotoType.URL;
                vcard.Pictures.Add(photo1);

                var request = System.Net.WebRequest.Create("https://jpeg.org/images/jpeg-logo-plain.png");
                System.Net.WebResponse response = request.GetResponse();
                Stream responseStream           = response.GetResponseStream();

                Photo photo2    = new Photo();
                photo2.Type     = PhotoType.Image;
                photo2.Encoding = PhotoEncoding.JPEG;
                photo2.Picture  = new System.Drawing.Bitmap(responseStream);
                vcard.Pictures.Add(photo2);

                Hobby hobby    = new Hobby();
                hobby.Activity = "Watching Hobbits";
                hobby.Level    = Level.Medium;
                vcard.Hobbies.Add(hobby);
                Interest interest = new Interest();
                interest.Activity = "Watching Hobbits";
                interest.Level    = Level.Medium;
                vcard.Interests.Add(interest);
                Expertise expertise = new Expertise();
                expertise.Area      = "Watching Hobbits";
                expertise.Level     = Level.Medium;
                vcard.Expertises.Add(expertise);

                vcard.Save(filePath, WriteOptions.Overwrite);
            });
            Assert.IsTrue(File.Exists(filePath));
        }
Example #13
0
 public HobbyBO(Hobby h)
 {
     _name     = h.Name;
     _personId = h.PersonId;
 }
        protected override void Seed(PresentationDbContext context)
        {
            var fr = new Language()
            {
                CultureIsoCode = "fr-FR"
            };

            context.Languages.Add(fr);
            var en = new Language()
            {
                CultureIsoCode = "en-GB"
            };

            context.Languages.Add(en);
            var es = new Language()
            {
                CultureIsoCode = "es-ES"
            };

            context.Languages.Add(es);
            var ca = new Language()
            {
                CultureIsoCode = "ca-ES"
            };

            context.Languages.Add(ca);

            var bacTexts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "Mon bac fr"
                },
                new Text()
                {
                    Language = es, Value = "Mon bac es"
                },
                new Text()
                {
                    Language = en, Value = "Mon bac en"
                },
                new Text()
                {
                    Language = ca, Value = "Mon bac ca"
                }
            };

            foreach (var bacText in bacTexts)
            {
                context.Texts.Add(bacText);
            }

            var btsTexts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "Mon BTS fr"
                },
                new Text()
                {
                    Language = es, Value = "Mon BTS es"
                },
                new Text()
                {
                    Language = en, Value = "Mon BTS en"
                },
                new Text()
                {
                    Language = ca, Value = "Mon BTS ca"
                }
            };

            context.Grades.Add(new Grade()
            {
                ObtainingDateTime = new DateTime(2008, 6, 30), Texts = bacTexts
            });
            context.Grades.Add(new Grade()
            {
                ObtainingDateTime = new DateTime(2010, 10, 1), Texts = btsTexts
            });

            var cat1Txt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "Categorie 1"
                },
                new Text()
                {
                    Language = es, Value = "Categoria 1"
                },
                new Text()
                {
                    Language = en, Value = "Category 1"
                },
                new Text()
                {
                    Language = ca, Value = "Categoria 1"
                }
            };

            foreach (var text in cat1Txt)
            {
                context.Texts.Add(text);
            }

            var cat2Txt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "Categorie 2"
                },
                new Text()
                {
                    Language = es, Value = "Categoria 2"
                },
                new Text()
                {
                    Language = en, Value = "Category 2"
                },
                new Text()
                {
                    Language = ca, Value = "Categoria 2"
                }
            };

            foreach (var text in cat2Txt)
            {
                context.Texts.Add(text);
            }

            var sk1ATxt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "compétence 1 a"
                },
                new Text()
                {
                    Language = es, Value = "comp 1 a"
                },
                new Text()
                {
                    Language = en, Value = "skill 1 a"
                },
                new Text()
                {
                    Language = ca, Value = "co 1 a"
                }
            };

            foreach (var text in sk1ATxt)
            {
                context.Texts.Add(text);
            }

            var sk1BTxt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "compétence 1 b"
                },
                new Text()
                {
                    Language = es, Value = "comp 1 b"
                },
                new Text()
                {
                    Language = en, Value = "skill 1 b"
                },
                new Text()
                {
                    Language = ca, Value = "co 1 b"
                }
            };

            foreach (var text in sk1BTxt)
            {
                context.Texts.Add(text);
            }

            var sk2ATxt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "compétence 2 a"
                },
                new Text()
                {
                    Language = es, Value = "comp 2 a"
                },
                new Text()
                {
                    Language = en, Value = "skill 2 a"
                },
                new Text()
                {
                    Language = ca, Value = "co 2 a"
                }
            };

            foreach (var text in sk2ATxt)
            {
                context.Texts.Add(text);
            }

            var sk2BTxt = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "compétence 2 b"
                },
                new Text()
                {
                    Language = es, Value = "comp 2 b"
                },
                new Text()
                {
                    Language = en, Value = "skill 2 b"
                },
                new Text()
                {
                    Language = ca, Value = "co 2 b"
                }
            };

            foreach (var text in sk2BTxt)
            {
                context.Texts.Add(text);
            }

            var cat1 = new SkillCategory()
            {
                DisplayPriority = 0, Texts = cat1Txt
            };
            var cat2 = new SkillCategory()
            {
                DisplayPriority = 0, Texts = cat2Txt
            };

            context.SkillGategories.Add(cat1);
            context.SkillGategories.Add(cat2);

            var sk1A = new Skill()
            {
                Category = cat1, KnowledgePercent = 50, Texts = sk1ATxt
            };
            var sk1B = new Skill()
            {
                Category = cat1, KnowledgePercent = 10, Texts = sk1BTxt
            };

            context.Skills.Add(sk1A);
            context.Skills.Add(sk1B);
            var sk2A = new Skill()
            {
                Category = cat2, KnowledgePercent = 40, Texts = sk2ATxt
            };
            var sk2B = new Skill()
            {
                Category = cat2, KnowledgePercent = 15, Texts = sk2BTxt
            };

            context.Skills.Add(sk2A);
            context.Skills.Add(sk2B);


            var work1Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "work1 fr"
                },
                new Text()
                {
                    Language = es, Value = "work1 es"
                },
                new Text()
                {
                    Language = en, Value = "work1 en"
                },
                new Text()
                {
                    Language = ca, Value = "work1 ca"
                }
            };

            foreach (var text in work1Texts)
            {
                context.Texts.Add(text);
            }

            var work2Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "work2 fr"
                },
                new Text()
                {
                    Language = es, Value = "work2 es"
                },
                new Text()
                {
                    Language = en, Value = "work2 en"
                },
                new Text()
                {
                    Language = ca, Value = "work2 ca"
                }
            };

            foreach (var text in work2Texts)
            {
                context.Texts.Add(text);
            }

            var work3Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "work3 fr"
                },
                new Text()
                {
                    Language = es, Value = "work3 es"
                },
                new Text()
                {
                    Language = en, Value = "work3 en"
                },
                new Text()
                {
                    Language = ca, Value = "work3 ca"
                }
            };

            foreach (var text in work3Texts)
            {
                context.Texts.Add(text);
            }

            var work4Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "work4 fr"
                },
                new Text()
                {
                    Language = es, Value = "work4 es"
                },
                new Text()
                {
                    Language = en, Value = "work4 en"
                },
                new Text()
                {
                    Language = ca, Value = "work4 ca"
                }
            };

            foreach (var text in work4Texts)
            {
                context.Texts.Add(text);
            }

            var work1 = new Work()
            {
                DisplayPriority = 0,
                Texts           = work1Texts
            };

            var work2 = new Work()
            {
                DisplayPriority = 1,
                Texts           = work2Texts
            };

            var work3 = new Work()
            {
                DisplayPriority = 2,
                Texts           = work3Texts
            };

            var work4 = new Work()
            {
                DisplayPriority = 1,
                Texts           = work4Texts
            };

            context.Works.Add(work1);
            context.Works.Add(work2);
            context.Works.Add(work3);
            context.Works.Add(work4);

            var job1Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "job1 fr"
                },
                new Text()
                {
                    Language = es, Value = "job1 es"
                },
                new Text()
                {
                    Language = en, Value = "job1 en"
                },
                new Text()
                {
                    Language = ca, Value = "job1 ca"
                }
            };

            foreach (var text in job1Texts)
            {
                context.Texts.Add(text);
            }

            var job2Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "job2 fr"
                },
                new Text()
                {
                    Language = es, Value = "job2 es"
                },
                new Text()
                {
                    Language = en, Value = "job2 en"
                },
                new Text()
                {
                    Language = ca, Value = "job2 ca"
                }
            };

            foreach (var text in job2Texts)
            {
                context.Texts.Add(text);
            }

            var job1 = new Job()
            {
                StarterDate = new DateTime(2010, 6, 1),
                EndDate     = new DateTime(2010, 8, 1),
                Works       = new List <Work>()
                {
                    work1, work2
                },
                Texts = job1Texts
            };

            context.Jobs.Add(job1);

            var job2 = new Job()
            {
                StarterDate = new DateTime(2011, 6, 1),
                Works       = new List <Work>()
                {
                    work3, work4
                },
                Texts = job2Texts
            };

            context.Jobs.Add(job2);

            var hobby1Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "hobby1 fr"
                },
                new Text()
                {
                    Language = es, Value = "hobby1 es"
                },
                new Text()
                {
                    Language = en, Value = "hobby1 en"
                },
                new Text()
                {
                    Language = ca, Value = "hobby1 ca"
                }
            };

            foreach (var text in hobby1Texts)
            {
                context.Texts.Add(text);
            }

            var hobby2Texts = new List <Text>()
            {
                new Text()
                {
                    Language = fr, Value = "hobby2 fr"
                },
                new Text()
                {
                    Language = es, Value = "hobby2 es"
                },
                new Text()
                {
                    Language = en, Value = "hobby2 en"
                },
                new Text()
                {
                    Language = ca, Value = "hobby2 ca"
                }
            };

            foreach (var text in hobby2Texts)
            {
                context.Texts.Add(text);
            }

            var hobby1 = new Hobby()
            {
                Texts = hobby1Texts
            };

            context.Hobbies.Add(hobby1);

            var hobby2 = new Hobby()
            {
                Texts = hobby2Texts
            };

            context.Hobbies.Add(hobby2);

            base.Seed(context);
        }
Example #15
0
 public Chosen(int id, string guestName, Hobby hobby)
 {
     Id = id;
     GuestName = guestName;
     Hobby = hobby;
 }
Example #16
0
        public IActionResult edit(int HobbyId)
        {
            Hobby HobbyToEdit = DbContext.Hobbies.FirstOrDefault(q => q.HobbyId == HobbyId);

            return(View(HobbyToEdit));
        }
Example #17
0
        protected override void Seed(NewProjectContext context)
        {
            var hobby1 = new Hobby()
            {
                Name = "Cricket"
            };
            var hobby2 = new Hobby()
            {
                Name = "Dancing"
            };
            var hobby3 = new Hobby()
            {
                Name = "Drawing"
            };

            var skill1 = new Skill()
            {
                Name = "C#"
            };
            var skill2 = new Skill()
            {
                Name = "ASP.NET"
            };
            var skill3 = new Skill()
            {
                Name = "ASP.NET Core"
            };
            var skill4 = new Skill()
            {
                Name = "Asure"
            };

            var course1 = new Course()
            {
                Name = "AAA"
            };
            var course2 = new Course()
            {
                Name = "BBB"
            };
            var course3 = new Course()
            {
                Name = "CCC"
            };
            var course4 = new Course()
            {
                Name = "DDD"
            };

            var student1 = new Student()
            {
                Address    = "1111 Main St",
                Course     = course1,
                GenderMale = true,
                Hobbies    = new List <Hobby>()
                {
                    hobby1
                },
                Password = "******",
                Skills   = new List <Skill>()
                {
                    skill1
                },
                UserName = "******",
            };
            var student2 = new Student()
            {
                Address    = "2222 Main St",
                Course     = course1,
                GenderMale = false,
                Hobbies    = new List <Hobby>()
                {
                    hobby1, hobby2
                },
                Password = "******",
                Skills   = new List <Skill>()
                {
                    skill1, skill2
                },
                UserName = "******",
            };

            context.Hobbies.AddRange(new List <Hobby>()
            {
                hobby1, hobby2, hobby3
            });
            context.Skills.AddRange(new List <Skill>()
            {
                skill1, skill2, skill3, skill4
            });
            context.Courses.AddRange(new List <Course>()
            {
                course1, course2, course3, course4
            });

            context.Students.Add(student1);
            context.Students.Add(student2);

            context.SaveChanges();
        }
Example #18
0
 public async Task ChooseAsync(Hobby hobby)
 => await RespondAsync(text : $":thumbsup: Your hobby is: {hobby}.");
Example #19
0
 public Guest(string name, Gender sex, Hobby hobby)
 {
     Name  = name;
     Sex   = sex;
     Hobby = hobby;
 }
Example #20
0
        public void Attached_OwnedMultipleLevelCollectionMappingWithAssociatedReload()
        {
            var hoby = new Hobby()
            {
                HobbyType = "Teste Hoby"
            };


            Models.MultiLevelTest multiLevelTest;
            Models.Hobby          hobby;
            using (var context = new TestDbContext())
            {
                multiLevelTest = context.MultiLevelTest.Add(new Models.MultiLevelTest
                {
                    Managers = new[] // test arrays as well
                    {
                        new Models.Manager
                        {
                            PartKey   = "xxx",
                            PartKey2  = 2,
                            Employees = new List <Models.Employee>
                            {
                                new Models.Employee
                                {
                                    Key       = "xsdf",
                                    FirstName = "Asdf",
                                    Hobbies   = Enumerable.Range(1, 2000).Select(s => hoby).ToList()
                                }
                            }
                        },
                        new Models.Manager
                        {
                            PartKey   = "xxx7",
                            PartKey2  = 3,
                            Employees = new List <Models.Employee>
                            {
                                new Models.Employee
                                {
                                    Key       = "xs7df",
                                    FirstName = "Asdf",
                                    Hobbies   = Enumerable.Range(1, 3000).Select(s => hoby).ToList()
                                }
                            }
                        }
                    }
                });

                hobby = context.Hobbies.Add(new Models.Hobby {
                    HobbyType = "Skiing"
                });
                context.SaveChanges();
                //} // Simulate detach

                // Graph changes

                // Should not update changes to hobby
                hobby.HobbyType = "Something Else";

                // Update changes to manager
                var manager = multiLevelTest.Managers.First();
                manager.FirstName = "Tester";

                // Update changes to employees
                var employeeToUpdate = manager.Employees.First();
                employeeToUpdate.Hobbies.Clear();
                employeeToUpdate.Hobbies.Add(hobby);

                manager.Employees.Add(new Models.Employee
                {
                    FirstName = "Tim",
                    Key       = "Tim1",
                    Hobbies   = Enumerable.Range(1, 2000).Select(s => hoby).ToList(),
                    Manager   = multiLevelTest.Managers.First()
                });

                //using (var context = new TestDbContext())
                //{
                GraphDiffConfiguration.ReloadAssociatedEntitiesWhenAttached = true;
                // Setup mapping
                context.UpdateGraph(multiLevelTest, map => map
                                    .OwnedCollection(x => x.Managers, withx => withx
                                                     .AssociatedCollection(pro => pro.Projects)
                                                     .OwnedCollection(p => p.Employees, with => with
                                                                      .AssociatedCollection(m => m.Hobbies)
                                                                      .OwnedEntity(m => m.Locker))));

                context.SaveChanges();

                GraphDiffConfiguration.ReloadAssociatedEntitiesWhenAttached = false;

                var result = context.MultiLevelTest
                             .Include("Managers.Employees.Hobbies")
                             .Include("Managers.Employees.Locker")
                             .Include("Managers.Projects")
                             .First();

                var updateManager  = result.Managers.Single(p => p.PartKey == manager.PartKey && p.PartKey2 == manager.PartKey2);
                var updateEmployee = updateManager.Employees.Single(p => p.Key == employeeToUpdate.Key);
                var updateHobby    = context.Hobbies.Single(p => p.Id == hobby.Id);

                Assert.IsTrue(updateManager.Employees.Count() == 2);
                Assert.IsTrue(result.Managers.First().FirstName == "Tester");
                Assert.IsTrue(updateEmployee.Hobbies.Count() == 1);
                Assert.IsTrue(updateEmployee.Hobbies.First().HobbyType == "Skiing");
                Assert.IsTrue(updateHobby.HobbyType == "Skiing");
                Assert.IsTrue(result.Managers.First().Employees.Any(p => p.Key == "Tim1"));
            }
        }
Example #21
0
 /// <summary>
 /// Method to remove a hobby from the hobby collection
 /// </summary>
 /// <param name="hobby">Hobby object to be removed</param>
 public void Remove(Hobby hobby)
 {
     List.Remove(hobby);
 }
Example #22
0
 public void UpdateHobby(Hobby hobby)
 {
     SetAuditFields(hobby);
     context.SaveChanges();
 }
Example #23
0
 public Hobby Create(Hobby Hobby)
 {
     _Hobbies.InsertOne(Hobby);
     return(Hobby);
 }
Example #24
0
        static void Main(string[] args)
        {
            var hobby1 = new Hobby();

            hobby1.HobbyId = 1;
            hobby1.Text    = "Astrology";
            hobby1.TextLt  = "Astrologija";

            var hobby2 = new Hobby(2, "Art", "Menas");

            var hobby3 = new Hobby {
                HobbyId = 3, Text = "Animation", TextLt = "Animacija"
            };

            var profession1 = new Profession(1);

            profession1.SetText("Kazkoks tekstas");

            var professionFactory = new ProfessionFactory();
            var profession2       = professionFactory.BuildEngineer();
            var profession3       = professionFactory.BuildPharmacist();

            /*
             * Sukurkite enum HumanoidGender su reiksmemis 0 - MALE, 1 FEMALE
             */

            var human1 = new Human(1, "Vardenis", "Pavardenis", EHumanoidGender.MALE, new DateTime(2000, 1, 1));

            Console.WriteLine($"human1 = {human1.FullName}");
            human1.FirstName = "Belekas";
            human1.FirstName = "Kitas";
            Console.WriteLine($"human1 = {human1.FullName}");
            Console.WriteLine($"human1 vardu keitimas \n{human1.NameChanges}");
            Console.WriteLine($"human1 amzius {human1.Age}");

            //TARPINE UZDUOTIS 1.-----------------------
            Console.WriteLine("------------------------------------");
            var person = new Person("Petras", "Petraitis", 20);

            person.VardasPavardeAmzius();
            person.Paseno();
            person.VardasPavardeAmzius();
            Console.WriteLine("------------------------------------");
            //------------------------------------------

            human1.Profession = new Profession(2, "Programmer", "Programuotojas");

            human1.Hobbies.Add(new Hobby(1, "Art", "Menas"));
            human1.Hobbies.Add(new Hobby(2, "Astrology", "Astrologija"));

            //TARPINE UZDUOTIS 2.-----------------------
            Console.WriteLine("------------------------------------");
            PersonInterests personInterests = new PersonInterests(person);

            personInterests.AddHobby(new Hobby(1, "Art", "Menas"));
            personInterests.AddHobby(new Hobby(2, "Astrology", "Astrologija"));
            personInterests.AddHobby(new Hobby(3, "Animation", "Animacija"));
            personInterests.AddHobby(new Hobby(4, "Computer games", "Kompiuteriniai žaidimai"));
            personInterests.AddHobby(new Hobby(5, "Football", "Futbolas"));
            Console.WriteLine("---ADD---");
            Console.WriteLine($"Person {personInterests.Person.Vardas} has hobbies:");
            foreach (var hobby in personInterests.Hobbies)
            {
                Console.WriteLine($"{hobby.Text}");
            }
            Console.WriteLine("---REMOVE---");
            personInterests.RemoveHobby(2, "Not interesting");
            personInterests.RemoveHobby(4, "Bored");
            personInterests.RemoveHobby(5, "Too hard");
            foreach (var hobby in personInterests.Hobbies)
            {
                Console.WriteLine($"{hobby.Text}");
            }
            Console.WriteLine("--HobbiesLog--");
            foreach (var log in personInterests.HobbiesLog)
            {
                Console.WriteLine($"{log}");
            }
            //------------------------------------------

            Console.WriteLine();
            Console.WriteLine("------- Press any key to continue -------");
            Console.ReadKey();
        }
Example #25
0
 public void Update(string id, Hobby HobbiesIn) =>
 _Hobbies.ReplaceOne(Hobby => Hobby.Id == id, HobbiesIn);
Example #26
0
 public Guest(string name, Gender sex, Hobby hobby)
 {
     Name = name;
     Sex = sex;
     Hobby = hobby;
 }