예제 #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            Task1Repo.SeedData();
            Task2Repo.SeedData();
            Task3Repo.SeedData();

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
예제 #2
0
        public void AddMember(AddMemberModel model)
        {
            Person newMember = Task1Repo.GetPerson(model.MemberId);
            Family family    = Task1Repo.GetFamily(model.FamilyId);

            if (newMember != null && family != null)
            {
                family.AddMember(newMember);
            }
        }
예제 #3
0
        public void CreateNewPerson(CreatePersonModel model)
        {
            Person newPerson = null;

            if (model.Age != 0 && !String.IsNullOrWhiteSpace(model.Name))
            {
                newPerson = new Person(model.Name, model.Age);
            }
            else if (model.Age != 0)
            {
                newPerson = new Person(model.Age);
            }
            else
            {
                newPerson = new Person();
            }

            Task1Repo.AddPerson(newPerson);
        }
예제 #4
0
        public void AddPersonsFromFile()
        {
            string rootPath = this.hostingEnvironment.ContentRootPath;

            string fullPath = rootPath + PERSONS_FILEPATH;

            if (!File.Exists(fullPath))
            {
                throw new FileNotFoundException("File not found at " + fullPath);
            }

            string text = File.ReadAllText(fullPath);

            PersonDto[] personDtos = JsonConvert.DeserializeObject <PersonDto[]>(text);

            foreach (var dto in personDtos)
            {
                Task1Repo.AddPerson(new Person(dto.Name, dto.Age));
            }
        }
예제 #5
0
 public List <Person> GetOlderThanThirty()
 {
     return(Task1Repo.GetPersons().Where(p => p.Age > 30).ToList());
 }
예제 #6
0
        public void CreateNewFamily(CreateFamilyModel model)
        {
            Family newFamily = new Family(model.FamilyName);

            Task1Repo.AddFamily(newFamily);
        }
예제 #7
0
 public IReadOnlyCollection <Person> GetAllPersons()
 {
     return(Task1Repo.GetPersons());
 }
예제 #8
0
 public IReadOnlyCollection <Family> GetAllFamilies()
 {
     return(Task1Repo.GetFamilies());
 }