public async Task <ActionResult <StoreDto> > UpdateStore( Guid storeId, [FromBody] UpdateStoreRequestModel requestModel) { StoreDto responseModel = await storeService.UpdateStore( storeId, new UpdateStoreDto() { Name = requestModel.Name, Description = requestModel.Description, BrandId = requestModel.BrandId, Address = requestModel.Address, IsDisabled = requestModel.IsDisabled, Location = new GeoEntry { Longitude = requestModel.Longitude, Latitude = requestModel.Latitude } }); if (responseModel == null) { return(InvalidRequest()); } return(Ok(responseModel)); }
public async Task <ActionResult> UpdateStoreAsync([FromBody] UpdateStoreRequestModel storeModel) { if (!Guid.TryParse(storeModel.Id, out var storeId)) { return(BadRequest()); } var store = await _storeRepository.FindOrDefaultAsync(storeId); if (store == null) { return(NotFound(new { Message = $"Store with id {storeModel.Id} not found." })); } store.Update(storeModel.Name, storeModel.StoreTypeId); _storeRepository.Update(store); await _storeRepository.UnitOfWork.SaveChangesAsync(); return(CreatedAtAction(nameof(GetByIdAsync), new { id = store.Id }, null)); }