예제 #1
0
        public ProductDto Delete(string id)
        {
            var product = _context.Products.Where(p => p.Id == id).FirstOrDefault();

            _context.Entry(product).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
            _context.SaveChanges();
            var deleted = MapToDto(product);

            return(deleted);
        }
        public ProductDto Update(string id, NewProductDto newProduct)
        {
            var product = MapToData(newProduct);

            product.Id = id;

            _context.Entry(product).State = EntityState.Modified;
            _context.SaveChanges();

            return(MapToDto(product));
        }