예제 #1
0
        public Result Update(Guid id, Pharmacy pharmacyModel)
        {
            var pharmacy = pharmacyRepository.GetById(id).ToResult("Pharmacy not found");

            return(Result.Combine(pharmacy)
                   .Tap(() => UpdatePharmacy(pharmacyModel, pharmacy.Value))
                   .Tap(() => pharmacyRepository.Update(pharmacy.Value))
                   .Tap(() => pharmacyRepository.SaveChanges()));
        }
        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());
        }