public async Task <IActionResult> EditPharmacy(int id, [FromBody] PharmacyAddDto model) { var pharmacy = await _pharmacyRepository.GetPharmacy(id); if (pharmacy == null) { return(BadRequest()); } pharmacy.PharmacyName = model.PharmacyName; pharmacy.Photo = model.Photo; _pharmacyRepository.UpdatePharmacy(pharmacy); if (_pharmacyRepository.SaveChanges() > 0) { return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> AddPharmacy([FromBody] PharmacyAddDto model) { if (!ModelState.IsValid) { return(BadRequest()); } var pharmacyResult = new Pharmacy() { PharmacyName = model.PharmacyName, Photo = model.Photo, Latitude = model.Latitude, Longitude = model.Longitude }; _pharmacyRepository.AddPharmacy(pharmacyResult); if (_pharmacyRepository.SaveChanges() > 0) { return(Ok()); } return(BadRequest()); }