Exemplo n.º 1
0
        public List <Models.DB.Catalogs> GetCatalogs()
        {
            var _context = new DAL.Models.ShopEntities();

            var listCategories = (from q in _context.Categories
                                  select new Models.DB.Categories
            {
                Id = q.Id,
                Name = q.Name,
                Active = q.Active
            }).ToList();

            var listCatalogs = (from q in _context.Catalogs
                                select new Models.DB.Catalogs
            {
                Id = q.Id,
                Name = q.Name,
                CategoryId = q.CategoryId,
                Categories = new Models.DB.Categories {
                    Id = (int)q.CategoryId
                }
            }).ToList();

            return(listCatalogs);
        }
Exemplo n.º 2
0
        public List <Models.DB.MethodPayment> GetMethodPayments()
        {
            var _context = new DAL.Models.ShopEntities();

            var listMethodPayments = (from q in _context.Categories
                                      select new Models.DB.MethodPayment
            {
                Id = q.Id,
                Name = q.Name,
                Active = q.Active
            }).ToList();

            return(listMethodPayments);
        }
Exemplo n.º 3
0
        public void CreateSaleDetails(int saleId,
                                      int productId,
                                      int quantity,
                                      double price)
        {
            var _context = new DAL.Models.ShopEntities();

            _context.SaleDetails.Add(new DAL.Models.SaleDetails {
                ProductId     = productId,
                Quantity      = quantity,
                SaleId        = saleId,
                SubtotalValue = price * quantity
            });
            _context.SaveChanges();
        }
Exemplo n.º 4
0
        public List <Models.DB.Products> GetProducts()
        {
            var _context = new DAL.Models.ShopEntities();

            var listProductPhotos = (from q in _context.ProductPhotos
                                     select new Models.DB.ProductPhotos
            {
                Id = q.Id,
                ProductId = q.ProductId,
                Guid = q.Guid,
                Extension = q.Extension
            }).ToList();

            var listProducts = (from q in _context.Products
                                select new Models.DB.Products
            {
                Id = q.Id,
                Name = q.Name,
                CategoryId = q.CategoryId,
                Price = q.Price,
                ShippingCost = q.ShippingCost,
                Warranty = q.Warranty,
                Description = q.Description,
                Quantity = q.Quantity,
                StateId = q.StateId,
                CustomerId = q.CustomerId,
                Categories = new Models.DB.Categories {
                    Id = (int)q.CategoryId
                },
                States = new Models.DB.States {
                    Id = (int)q.StateId
                },
                Customer = new Models.DB.Customer {
                    Id = (int)q.CustomerId
                }
            }).ToList();

            foreach (var item in listProducts)
            {
                item.Guid      = listProductPhotos.Where(x => x.ProductId == item.Id).Select(x => x.Guid).FirstOrDefault();
                item.Extension = listProductPhotos.Where(x => x.ProductId == item.Id).Select(x => x.Extension).FirstOrDefault();
            }

            return(listProducts);
        }
Exemplo n.º 5
0
        public int CreateSale(int methodPaymentId,
                              double totalValue,
                              int customerId)
        {
            var _context = new DAL.Models.ShopEntities();

            _context.Sales.Add(new DAL.Models.Sales {
                MethodPaymentId = methodPaymentId,
                TotalValue      = totalValue,
                Date            = DateTime.Now,
                CustomerId      = customerId
            });
            _context.SaveChanges();

            var id = (from q in _context.Sales
                      select q.Id).LastOrDefault();

            return(id);
        }
Exemplo n.º 6
0
        public List <Models.DB.Customer> GetCustomer(string userId)
        {
            var _context = new DAL.Models.ShopEntities();

            var listCustomer = (from q in _context.Customer
                                where q.UserId == userId
                                select new Models.DB.Customer
            {
                Id = q.Id,
                DocumentTypeId = q.DocumentTypeId,
                DocumentNumber = q.DocumentNumber,
                FirstName = q.FirstName,
                SecondName = q.SecondName,
                Surname = q.Surname,
                SecondSurname = q.SecondSurname,
                Telephone = q.Telephone,
                Address = q.Address,
                CityId = q.CityId,
                UserId = q.UserId,
            }).ToList();

            return(listCustomer);
        }