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); }
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); }
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(); }
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); }
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); }
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); }