public async Task <IActionResult> PutSickness(int id, Sickness sickness) { if (string.IsNullOrEmpty(sickness.SicknessName) ) { return(BadRequest("SicknessName is required.")); } if (id != sickness.SicknessId) { return(BadRequest()); } sickness.SicknessName = System.Net.WebUtility.HtmlEncode(sickness.SicknessName); _context.Entry(sickness).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SicknessExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutContinent(string id, Continent continent) { if (string.IsNullOrEmpty(continent.ContinentName) ) { return(BadRequest("ContinentName is required.")); } if (id != continent.ContinentName) { return(BadRequest()); } continent.ContinentName = System.Net.WebUtility.HtmlEncode(continent.ContinentName); _context.Entry(continent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContinentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,Occupation,Gender,PictureUrl,Votes")] People people) { if (ModelState.IsValid) { _context.Add(people); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(people)); }
public async Task <IActionResult> PutPeople(int id, People people) { if (string.IsNullOrEmpty(people.FirstName) || string.IsNullOrEmpty(people.LastName) || string.IsNullOrEmpty(people.Occupation) || string.IsNullOrEmpty(people.Gender) || string.IsNullOrEmpty(people.PictureUrl) ) { return(BadRequest("FirstName, LastName, Occupation, Gender and PictureUrl are required.")); } if (id != people.Id) { return(BadRequest()); } if (!string.IsNullOrEmpty(people.PictureUrl)) { if (!Helpers.IsPictureInLegitToonList(people.PictureUrl, _env, Request)) { return(BadRequest("Picture must be among those at /api/pictures")); } } people.FirstName = WebUtility.HtmlEncode(people.FirstName); people.LastName = WebUtility.HtmlEncode(people.LastName); people.Occupation = WebUtility.HtmlEncode(people.Occupation); people.Gender = WebUtility.HtmlEncode(people.Gender); people.PictureUrl = WebUtility.HtmlEncode(people.PictureUrl); _context.Entry(people).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PeopleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutHospital(int id, Hospital hospital) { if (string.IsNullOrEmpty(hospital.Name) || string.IsNullOrEmpty(hospital.Street) || string.IsNullOrEmpty(hospital.City) || string.IsNullOrEmpty(hospital.Province) || string.IsNullOrEmpty(hospital.Country) ) { return(BadRequest("Name, Street, City, Province, and Country are required.")); } if (id != hospital.HospitalId) { return(BadRequest()); } hospital.Name = System.Net.WebUtility.HtmlEncode(hospital.Name); hospital.Street = System.Net.WebUtility.HtmlEncode(hospital.Street); hospital.City = System.Net.WebUtility.HtmlEncode(hospital.City); hospital.Province = System.Net.WebUtility.HtmlEncode(hospital.Province); hospital.PostalCode = System.Net.WebUtility.HtmlEncode(hospital.PostalCode); hospital.Country = System.Net.WebUtility.HtmlEncode(hospital.Country); _context.Entry(hospital).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HospitalExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPatient(int id, Patient patient) { if (string.IsNullOrEmpty(patient.LastName) || string.IsNullOrEmpty(patient.FirstName) || string.IsNullOrEmpty(patient.Street) || string.IsNullOrEmpty(patient.City) || string.IsNullOrEmpty(patient.Province) || string.IsNullOrEmpty(patient.Country) ) { return(BadRequest("LastName, FirstName, Street, City, Province and Country are required.")); } if (id != patient.PatientId) { return(BadRequest()); } patient.LastName = System.Net.WebUtility.HtmlEncode(patient.LastName); patient.FirstName = System.Net.WebUtility.HtmlEncode(patient.FirstName); patient.Street = System.Net.WebUtility.HtmlEncode(patient.Street); patient.City = System.Net.WebUtility.HtmlEncode(patient.City); patient.Province = System.Net.WebUtility.HtmlEncode(patient.Province); patient.Country = System.Net.WebUtility.HtmlEncode(patient.Country); _context.Entry(patient).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PatientExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutRestaurant(int id, Restaurant restaurant) { if (string.IsNullOrEmpty(restaurant.RestaurantName) || string.IsNullOrEmpty(restaurant.Street) || string.IsNullOrEmpty(restaurant.City) || string.IsNullOrEmpty(restaurant.Province) || string.IsNullOrEmpty(restaurant.Country) || string.IsNullOrEmpty(restaurant.FoodType) ) { return(BadRequest("RestaurantName, Street, City, Province Country and FoodType are required.")); } if (id != restaurant.RestaurantId) { return(BadRequest()); } restaurant.Street = System.Net.WebUtility.HtmlEncode(restaurant.Street); restaurant.Country = System.Net.WebUtility.HtmlEncode(restaurant.Country); restaurant.City = System.Net.WebUtility.HtmlEncode(restaurant.City); restaurant.RestaurantName = System.Net.WebUtility.HtmlEncode(restaurant.RestaurantName); restaurant.Province = System.Net.WebUtility.HtmlEncode(restaurant.Province); restaurant.FoodType = System.Net.WebUtility.HtmlEncode(restaurant.FoodType); _context.Entry(restaurant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RestaurantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutVehicle(string id, Vehicle vehicle) { if (string.IsNullOrEmpty(vehicle.Model) || string.IsNullOrEmpty(vehicle.Fuel) || string.IsNullOrEmpty(vehicle.Type) || string.IsNullOrEmpty(vehicle.VehicleManufacturerName) ) { return(BadRequest("Model, Fuel, Type and VehicleManufacturerName are required.")); } if (id != vehicle.Model) { return(BadRequest()); } vehicle.Model = System.Net.WebUtility.HtmlEncode(vehicle.Model); vehicle.Fuel = System.Net.WebUtility.HtmlEncode(vehicle.Fuel); vehicle.Type = System.Net.WebUtility.HtmlEncode(vehicle.Type); vehicle.VehicleManufacturerName = System.Net.WebUtility.HtmlEncode(vehicle.VehicleManufacturerName); _context.Entry(vehicle).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutStudent(string id, Student student) { if (string.IsNullOrEmpty(student.FirstName) || string.IsNullOrEmpty(student.LastName) || string.IsNullOrEmpty(student.School) || string.IsNullOrEmpty(student.StudentId) ) { return(BadRequest("FirstName, LastName, School and StudentId are required.")); } if (id != student.StudentId) { return(BadRequest()); } student.StudentId = WebUtility.HtmlEncode(student.StudentId); student.FirstName = WebUtility.HtmlEncode(student.FirstName); student.LastName = WebUtility.HtmlEncode(student.LastName); student.School = WebUtility.HtmlEncode(student.School); _context.Entry(student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTeam(string id, Team team) { if (string.IsNullOrEmpty(team.TeamName) || string.IsNullOrEmpty(team.City) || string.IsNullOrEmpty(team.Province) || string.IsNullOrEmpty(team.Country) ) { return(BadRequest("TeamName, City, Province and Country are required.")); } if (id != team.TeamName) { return(BadRequest()); } team.Country = System.Net.WebUtility.HtmlEncode(team.Country); team.City = System.Net.WebUtility.HtmlEncode(team.City); team.TeamName = System.Net.WebUtility.HtmlEncode(team.TeamName); team.Province = System.Net.WebUtility.HtmlEncode(team.Province); _context.Entry(team).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeamExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutPlayer(int id, Player player) { if (string.IsNullOrEmpty(player.Position) || string.IsNullOrEmpty(player.FirstName) || string.IsNullOrEmpty(player.LastName) || string.IsNullOrEmpty(player.TeamName) ) { return(BadRequest("Position, TeamName, FirstName and LastName are required.")); } if (id != player.PlayerId) { return(BadRequest()); } player.Position = System.Net.WebUtility.HtmlEncode(player.Position); player.FirstName = System.Net.WebUtility.HtmlEncode(player.FirstName); player.LastName = System.Net.WebUtility.HtmlEncode(player.LastName); player.TeamName = System.Net.WebUtility.HtmlEncode(player.TeamName); _context.Entry(player).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlayerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAthlete(int id, Athlete athlete) { if (string.IsNullOrEmpty(athlete.Country) || string.IsNullOrEmpty(athlete.FirstName) || string.IsNullOrEmpty(athlete.LastName) ) { return(BadRequest("Country, FirstName and LastName are required.")); } if (id != athlete.AthleteId) { return(BadRequest()); } athlete.Country = System.Net.WebUtility.HtmlEncode(athlete.Country); athlete.FirstName = System.Net.WebUtility.HtmlEncode(athlete.FirstName); athlete.LastName = System.Net.WebUtility.HtmlEncode(athlete.LastName); _context.Entry(athlete).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AthleteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutInstructor(int id, Instructor instructor) { if (string.IsNullOrEmpty(instructor.Email) || string.IsNullOrEmpty(instructor.FirstName) || string.IsNullOrEmpty(instructor.LastName) ) { return(BadRequest("Email, FirstName and LastName are required.")); } if (id != instructor.InstructorId) { return(BadRequest()); } instructor.Email = System.Net.WebUtility.HtmlEncode(instructor.Email); instructor.FirstName = System.Net.WebUtility.HtmlEncode(instructor.FirstName); instructor.LastName = System.Net.WebUtility.HtmlEncode(instructor.LastName); _context.Entry(instructor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InstructorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProvince(int id, Province province) { if (string.IsNullOrEmpty(province.Name) || string.IsNullOrEmpty(province.CapitalCity) || string.IsNullOrEmpty(province.CountryName) ) { return(BadRequest("Name, CapitalCity and CountryName are required.")); } if (id != province.ProvinceId) { return(BadRequest()); } province.Name = System.Net.WebUtility.HtmlEncode(province.Name); province.CapitalCity = System.Net.WebUtility.HtmlEncode(province.CapitalCity); province.CountryName = System.Net.WebUtility.HtmlEncode(province.CountryName); _context.Entry(province).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProvinceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMovie(int id, Movie movie) { if (string.IsNullOrEmpty(movie.Name) || string.IsNullOrEmpty(movie.DirectorFirstName) || string.IsNullOrEmpty(movie.DirectorLastName) ) { return(BadRequest("Name, DirectorFirstName and DirectorLastName are required.")); } if (id != movie.MovieId) { return(BadRequest()); } movie.Name = System.Net.WebUtility.HtmlEncode(movie.Name); movie.DirectorLastName = System.Net.WebUtility.HtmlEncode(movie.DirectorLastName); movie.DirectorLastName = System.Net.WebUtility.HtmlEncode(movie.DirectorLastName); _context.Entry(movie).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMedicine(int id, Medicine medicine) { if (string.IsNullOrEmpty(medicine.Name) || string.IsNullOrEmpty(medicine.DosageUnit) ) { return(BadRequest("Name and DosageUnit are required.")); } if (id != medicine.MedicineId) { return(BadRequest()); } medicine.Name = System.Net.WebUtility.HtmlEncode(medicine.Name); medicine.DosageUnit = System.Net.WebUtility.HtmlEncode(medicine.DosageUnit); _context.Entry(medicine).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MedicineExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutOrganism(int id, Organism organism) { if (string.IsNullOrEmpty(organism.Name) || string.IsNullOrEmpty(organism.SpecieName) ) { return(BadRequest("Name and SpecieName are required.")); } if (id != organism.OrganismId) { return(BadRequest()); } organism.Name = System.Net.WebUtility.HtmlEncode(organism.Name); organism.SpecieName = System.Net.WebUtility.HtmlEncode(organism.SpecieName); _context.Entry(organism).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrganismExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutFoodCategory(int id, FoodCategory foodCategory) { if (string.IsNullOrEmpty(foodCategory.Name) || string.IsNullOrEmpty(foodCategory.Description) ) { return(BadRequest("Name and description are required.")); } if (id != foodCategory.FoodCategoryId) { return(BadRequest()); } foodCategory.Name = System.Net.WebUtility.HtmlEncode(foodCategory.Name); foodCategory.Description = System.Net.WebUtility.HtmlEncode(foodCategory.Description); _context.Entry(foodCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }