Example #1
0
        public void Execute(LocationDto request)
        {
            validations.ValidateAndThrow(request);

            var location = new Location
            {
                CityName = request.CityName
            };

            _context.Add(location);

            _context.SaveChanges();
        }
Example #2
0
        public void Execute(LocationDto request)
        {
            var location = _context.Locations.Find(request.Id);

            if (location == null)
            {
                throw new EntityNotFoundException(request.Id, typeof(Location));
            }

            _validator.ValidateAndThrow(request);

            _mapper.Map(request, location);

            _context.SaveChanges();
        }