コード例 #1
0
ファイル: RegionCityService.cs プロジェクト: bojbaj/Ganjeh
        public async Task <TypedResult <CityDTO> > Update(UpdateRegionCity regionCity)
        {
            try
            {
                if (regionCity.Id.Equals(Guid.Empty))
                {
                    throw new InvalidOperationException(ErrorMessages.ID_IS_REQUIRED);
                }
                RegionCity existsRecord = await regionCityRepo.FindById(regionCity.Id);

                if (existsRecord == null)
                {
                    throw new InvalidOperationException(ErrorMessages.THIS_RECORD_DOES_NOT_EXISTS);
                }

                existsRecord.RegionStateId = regionCity.StateId;
                existsRecord.Title         = regionCity.Title;
                RegionCity result = await regionCityRepo.Update(existsRecord);

                return(new TypedResult <CityDTO>(_mapper.Map <CityDTO>(result)));
            }
            catch (Exception ex)
            {
                return(new TypedResult <CityDTO>(ex));
            }
        }
コード例 #2
0
        public async Task <IActionResult> Put([FromBody] UpdateRegionCity model)
        {
            var result = await regionServices.Update(model);

            if (result.Status)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }