예제 #1
0
        public List <ICustomer> GetAllCustomer()
        {
            using (InvDb ctx = new InvDb())
            {
                var customersDb = ctx.customers.ToList();
                var customers   = customersDb.Select(CustomerDtoToCustomer).ToList();

                return(customers);
            }
        }
예제 #2
0
        public void AddCustomer(ICustomer customer)
        {
            customer customerToCreate = CustomerToCustomerDto(customer);

            using (InvDb ctx = new InvDb())
            {
                customer customers = ctx.customers.Add(customerToCreate);
                ctx.SaveChanges();
            }
        }
        public List <ILocation> GetAllLocation()
        {
            var locations = new List <ILocation>();

            using (InvDb ctx = new InvDb())
            {
                var locationWithPods = ctx.view_locationWithPodV5.ToList();
                locations = locationWithPods.Select(l => LocationDtoToLocation(l)).ToList();
            }

            return(locations);
        }
예제 #4
0
        public bool DeleteCustomer(ICustomer customer)
        {
            using (InvDb ctx = new InvDb())
            {
                customer customerToDelete = ctx.customers.Find(customer.Id);
                if (customerToDelete != null)
                {
                    customer customers = ctx.customers.Remove(customerToDelete);
                    var      b         = ctx.SaveChanges();

                    return(b > 0);
                }

                throw new ArgumentException("Customer does not exist");
            }
        }
예제 #5
0
 public void UpdateCustomer(ICustomer c)
 {
     using (InvDb ctx = new InvDb())
     {
         customer customerToUpdate = ctx.customers.Find(c.Id);
         if (customerToUpdate != null)
         {
             customerToUpdate.kundenNr   = c.CustomerNumber;
             customerToUpdate.email      = c.Email;
             customerToUpdate.surname    = c.Firstname;
             customerToUpdate.name       = c.Lastname;
             customerToUpdate.id         = c.Id;
             customerToUpdate.password   = Encryption.Encrypt(c.Password);
             customerToUpdate.phone      = c.Phone;
             customerToUpdate.website    = c.Website;
             customerToUpdate.address_id = c.Fk_AddressId;
             ctx.SaveChanges();
         }
     }
 }