public void Add_Normal_Conditions() { var repo = new SchoolRepository(); var school = new School("North High School"); repo.Add(school); }
public void Add_Name_Null() { Assert.Throws <ArgumentNullException>(() => { var repo = new SchoolRepository(); var school = new School(null); repo.Add(school); }); }
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); }); }
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"); }
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()); }
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.")); }
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")); }