예제 #1
0
        public void Add_Normal_Conditions()
        {
            var repo   = new SchoolRepository();
            var school = new School("North High School");

            repo.Add(school);
        }
예제 #2
0
 public void Add_Name_Null()
 {
     Assert.Throws <ArgumentNullException>(() => {
         var repo   = new SchoolRepository();
         var school = new School(null);
         repo.Add(school);
     });
 }
예제 #3
0
 public void Edit_Name_Null()
 {
     Assert.Throws <ArgumentNullException>(() => {
         var repo   = new SchoolRepository();
         var school = new School("West High School");
         repo.Add(school);
         school.Name = null;
         repo.Edit(school);
     });
 }
예제 #4
0
        public void Edit_Normal_Conditions()
        {
            var repo   = new SchoolRepository();
            var school = new School("Scotland High School");

            repo.Add(school);
            school.Name = "South High School";
            repo.Edit(school);
            Assert.True(repo.GetAll().Last().Name == "South High School");
        }
예제 #5
0
        public void Delete_Normal_Conditions()
        {
            var repo   = new SchoolRepository();
            var school = new School("East High School");
            var count  = repo.GetAll().Count();

            repo.Add(school);
            repo.Delete(school);
            Assert.True(count == repo.GetAll().Count());
        }
예제 #6
0
        public async Task <IActionResult> Add(SchoolInput input)
        {
            string[] roles = { "Admin" };
            var      token = HttpContext.Request.Headers["Authorization"].Last().Split(" ").Last();

            if (RoleService.CheckRoles(token, roles, _userManager))
            {
                var repo   = new SchoolRepository();
                var school = new School(input.Name);
                repo.Add(school);
                return(Ok());
            }
            return(Unauthorized("Only Admin have access to this controller."));
        }
예제 #7
0
        public JsonResult Add(SchoolModel school)
        {
            using (var schoolRepository = new SchoolRepository())
            {
                schoolRepository.Add(new SchoolDTO
                {
                    City       = school.City,
                    Director   = school.Director,
                    Email      = school.Email,
                    Name       = school.Name,
                    NIP        = school.NIP,
                    Number     = school.Number,
                    PostalCode = school.PostalCode,
                    Street     = school.Street,
                    Telephone  = school.Telephone
                });
            }

            return(Json("ok"));
        }