public Model.Customer AddNewCustomer(Model.Customer customer)
 {
     Entity.Customer newCust = _context.Customers.Add(_mapper.ParseCustomer(customer, true)).Entity;
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
     return(_mapper.ParseCustomer(newCust));
 }
Ejemplo n.º 2
0
 public void UpdateCustomer(Customer customer2BUpdated)
 {
     Entity.Customer oldCustomer = _context.Customers.Find(customer2BUpdated.CustID);
     _context.Entry(oldCustomer).CurrentValues.SetValues(_mapper.ParseCustomer(customer2BUpdated));
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
 }
 public Model.Customer GetCustomerByName(string name)
 {
     Entity.Customer found = _context.Customers
                             .AsNoTracking()
                             .FirstOrDefault(customer => customer.CName == name);
     return(_mapper.ParseCustomer(found));
 }
 public Model.Customer GetCustomerById(int id)
 {
     Entity.Customer found = _context.Customers
                             .AsNoTracking()
                             .FirstOrDefault(customer => customer.Id == id);
     return(_mapper.ParseCustomer(found));
 }
Ejemplo n.º 5
0
 public Model.Customer ParseCustomer(Entity.Customer customer)
 {
     return(new Model.Customer
     {
         CustomerName = customer.Name,
         CustomerEmail = customer.Email,
         Id = customer.Id
     });
 }
Ejemplo n.º 6
0
 public Model.Customer ParseCustomer(Entity.Customer customer)
 {
     return(new Model.Customer
     {
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         PhoneNumber = customer.PhoneNumber
     });
 }
Ejemplo n.º 7
0
 public Model.Customer GetCustomer(Customer customer)
 {
     Entity.Customer found = _context.Customers.FirstOrDefault(obj =>
                                                               obj.LastName == customer.FullName &&
                                                               obj.MiddleName == customer.MiddleName &&
                                                               obj.FirstName == customer.FirstName
                                                               );
     return((found == null) ? null : new Model.Customer(found.Id, found.FirstName, found.MiddleName, found.LastName, found.PhoneNumber));
 }
Ejemplo n.º 8
0
 public Model.Customer GetCustomer(Model.Customer customer)
 {
     Entity.Customer found = _context.Customers.FirstOrDefault(custo => custo.FirstName == customer.FirstName && custo.LastName == customer.LastName && custo.Birthdate == customer.Birthdate && custo.PhoneNumber == customer.PhoneNumber && custo.Email == customer.Email && custo.MailAddress == customer.MailAddress);
     if (found == null)
     {
         return(null);
     }
     Log.Information("DL sent customer to BL");
     return(new Model.Customer(found.CustomerId, found.FirstName, found.LastName, found.Birthdate, found.PhoneNumber, found.Email, found.MailAddress));
 }
Ejemplo n.º 9
0
 public Model.Customer ParseCustomer(Entity.Customer customer)
 {
     return(new Model.Customer
     {
         CustID = customer.Id,
         FirstName = customer.FirstName,
         LastName = customer.LastName,
         Email = customer.Email,
         PhoneNumber = customer.PhoneNumber
     });
 }
Ejemplo n.º 10
0
 public Model.Customer ParseCustomer(Entity.Customer customer)
 {
     return(new Model.Customer
     {
         CustomerName = customer.CustomerName,
         CustomerEmail = customer.CustomerEmail,
         CustomerPasswordHash = customer.CustomerPasswordHash,
         CustomerPhone = customer.CustomerPhone,
         CustomerAddress = customer.CustomerAddress,
         Id = customer.Id
     });
 }
Ejemplo n.º 11
0
        public Model.Customer GetCustomer(string username)
        {
            Entity.Customer found = _context.Customers.FirstOrDefault(custom => custom.Username == username);

            if (found == null)
            {
                return(null);
            }
            else
            {
                return(new Model.Customer(found.Name, found.Username));
            }
        }
Ejemplo n.º 12
0
        //  public Model.Customer ParseCustomer(int? customer)
        // {

        //     return new Model.Customer
        //     {
        //         CustomerName = customerTemp.CustomerName,
        //         PhoneNumber = customerTemp.PhoneNumber,
        //         CarType = (Model.CarType)customerTemp.CarType,
        //         Id = (int)customerTemp.Id
        //     };
        // }
        // //get

        public Model.Customer ParseCustomer(Entity.Customer customer)
        {
            customerTemp = new Model.Customer
            {
                CustomerName = customer.CustomerName,
                PhoneNumber  = customer.PhoneNumber,
                CarType      = (Model.CarType)customer.CarType,
                Id           = (int)customer.Id
            };
            return(new Model.Customer
            {
                CustomerName = customer.CustomerName,
                PhoneNumber = customer.PhoneNumber,
                CarType = (Model.CarType)customer.CarType,
                Id = (int)customer.Id
            });
        }
        public Model.Customer ParseCustomer(Entity.Customer customer)
        {
            if (customer is null)
            {
                return(null);
            }
            List <Model.Order> orders = new List <Model.Order>();

            if (customer.Orders is not null && customer.Orders.Count > 0)
            {
                foreach (Entity.Order order in customer.Orders)
                {
                    orders.Add(ParseOrder(order));
                }
            }
            return(new Model.Customer
            {
                Id = customer.Id,
                Name = customer.CName,
                Orders = orders
            });
        }
Ejemplo n.º 14
0
 public Model.Customer GetCustomer(string phoneNumber)
 {
     Entity.Customer found = _context.Customers.FirstOrDefault(obj => obj.PhoneNumber == phoneNumber);
     return((found == null) ? null : new Model.Customer(found.Id, found.FirstName, found.MiddleName, found.LastName, found.PhoneNumber));
 }
Ejemplo n.º 15
0
 public Model.Customer ParseCustomer(Entity.Customer customer)
 {
     Model.Customer newCustomer = new Model.Customer(customer.FirstName, customer.LastName, customer.PhoneNumber);
     newCustomer.CustID = customer.CustId;
     return(newCustomer);
 }