예제 #1
0
        public async Task <TypedResult <CountryDTO> > Update(UpdateRegionCountry regionCountry)
        {
            try
            {
                if (regionCountry.Id.Equals(Guid.Empty))
                {
                    throw new InvalidOperationException(ErrorMessages.ID_IS_REQUIRED);
                }
                RegionCountry existsRecord = await regionCountryRepo.FindById(regionCountry.Id);

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

                existsRecord.Title = regionCountry.Title;
                RegionCountry result = await regionCountryRepo.Update(existsRecord);

                return(new TypedResult <CountryDTO>(_mapper.Map <CountryDTO>(result)));
            }
            catch (Exception ex)
            {
                return(new TypedResult <CountryDTO>(ex));
            }
        }
예제 #2
0
        public async Task <IActionResult> Put([FromBody] UpdateRegionCountry model)
        {
            var result = await regionServices.Update(model);

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