public async Task Update(City entity) { var model = _mapper.Map <Models.City>(entity); _context.Entry(model).Property(e => e.Name).IsModified = true; _context.Entry(model).Property(e => e.Description).IsModified = true; await _context.SaveChangesAsync(); }
public async Task <int> CreateAsync(CityDto cityDto) { if (cityDto != null && string.IsNullOrWhiteSpace(cityDto.Name) == false) { // depending on the business rules, vaidate the DTO. var city = cityDto.ToCity(); _citiesContext.Cities.Add(city); await _citiesContext.SaveChangesAsync(); return(city.Id); } return(-1); }