Esempio n. 1
0
        /// <summary>
        /// updates a customer and order history in the database
        /// </summary>
        /// <param name="customer">customer object to update the database with</param>
        public void UpdateCustomer(Business.Customer customer)
        {
            Customers currentEntity = _context.Customers.Find(customer.Id);
            Customers newEntity     = Mapper.MapCustomerToOrders(customer);

            Log.Information("Updated cutomer {FirstName} {LastName}", customer.FirstName, customer.LastName);
            _context.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
        /// <summary>
        /// updates a customer and order history in the database
        /// </summary>
        /// <param name="customer">customer object to update the database with</param>
        public void UpdateCustomer(Customer customer)
        {
            Customers currentEntity = _context.Customers
                                      .Include(o => o.Orders)
                                      .ThenInclude(po => po.ProductOrdered)
                                      .First(c => c.Id == customer.Id);

            Customers newEntity = Mapper.MapCustomerToOrders(customer);

            Log.Information("Updated cutomer {FirstName} {LastName}", customer.FirstName, customer.LastName);
            _context.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
Esempio n. 3
0
        public void UpdateCigar(Library.Models.Cigar cigar)
        {
            _logger.LogInformation("Updating cigar with ID {cigarId}", cigar.Id);

            Cigar currentEntity = _dbContext.Cigar.Find(cigar.Id);
            Cigar newEntity     = Mapper.Map(cigar);

            _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity);
        }
 public void EditCustomer(CustomerImp _customer)
 {
     _db.Entry(_db.Customers.Find(_customer.Id)).CurrentValues.SetValues(Mapper.Map(_customer));
     _db.SaveChanges();
 }