public ProductDetail GetProductDetail(int ProdcutID) { var imageRepository = RepositoryContainer.GetInstance <ProductImageRepository>(); var stockRepository = RepositoryContainer.GetInstance <StockRepository>(); var products = productsRepository.GetByProduct_ID(ProdcutID); var allImage = imageRepository.GetByProduct_ID(ProdcutID); var Image = allImage.Select(x => "/Images/Products/" + x.Image).ToList(); var stock = stockRepository.GetByProductID(ProdcutID); Dictionary <string, List <string> > ColorSize = new Dictionary <string, List <string> >(); foreach (var color in stock.Select(x => x.Color).Distinct()) { var _size = stock.Where(x => x.Color == color).Select(x => x.Size).Reverse().ToList(); ColorSize.Add(color, _size); } ; return(new ProductDetail() { ID = products.Product_ID, Name = products.Product_Name, Comments = products.Comments, Price = products.UnitPrice, Image = Image, ColorSize = ColorSize }); }
public bool SearchAccount(string account) { if (RepositoryContainer.GetInstance <CustomerRepository>().GetByAccount(account) == null) { return(true); } else { return(false); } }
public bool UpdateCustomerDetail(string Account, string Password, string Name, string Email, string Phone, string Address) { try { var C_repository = RepositoryContainer.GetInstance <CustomerRepository>(); C_repository.UpdatePassword(Account, Password); return(true); } catch { return(false); } }
public bool DeleteOrderDetail(int order_Detail_ID) { try { Order_DetailsRepository.Delete(order_Detail_ID); var order_ID = Order_DetailsRepository.GetByOrder_Details_ID(order_Detail_ID).Order_ID; var o = RepositoryContainer.GetInstance <OrdersRepository>(); o.UpdateTotalMoney(order_ID); return(true); } catch { return(false); } }
public bool UpdateCustomerDetail(string Account, string Name, string Email, string Phone, string Address) { try { var C_repository = RepositoryContainer.GetInstance <CustomerRepository>(); C_repository.Update(new Customers { Account = Account, Address = Address, Email = Email, Name = Name, Phone = Phone }); return(true); } catch { return(false); } }
public bool CreateShoppingCart(string _account, int Product_ID, int Quantity, string Size, string Color) { //宣告 庫存,購物車,產品 的 Rpository StockRepository sizeQuantityRepository = RepositoryContainer.GetInstance <StockRepository>(); ShoppingCartRepository shoppingCart = RepositoryContainer.GetInstance <ShoppingCartRepository>(); ProductsRepository products = RepositoryContainer.GetInstance <ProductsRepository>(); //先取得那項產品庫存 放到 stock var stock = sizeQuantityRepository.GetByPK(Product_ID, Size, Color); //如果庫存量少與需求量 回傳 false if (stock.Quantity < Quantity) { return(false); } //取得 目前 Account 的 購物車 var myCart = shoppingCart.GetByAccount(_account); //查看購物車是否有那項產品 //如果有 把需要的數量 新增 進原有的購物車的裡面 var items = myCart.FirstOrDefault(x => (x.Product_ID == Product_ID) && (x.size == Size) && (x.Color == Color)); if (items != null) { //去更新購物車的那項產品 shoppingCart.Update(items.Shopping_Cart_ID, items.Quantity + Quantity); } else { //如果購物車沒有那項產品就新增一項產品進到購物車 var model = new Shopping_Cart() { Account = _account, Product_ID = Product_ID, size = Size, UnitPrice = products.GetByProduct_ID(Product_ID).UnitPrice, Quantity = (short)Quantity, Color = Color, }; shoppingCart.Create(model); } return(true); }
public CustomerDetail GetCustomerDetail(string Account) { var C_repository = RepositoryContainer.GetInstance <CustomerRepository>(); var O_repostiory = RepositoryContainer.GetInstance <OrdersRepository>(); var OD_repostiory = RepositoryContainer.GetInstance <Order_DetailsRepository>(); var result = C_repository.GetByAccount(Account); var customer = new CustomerDetail { CustomerName = result.Name, Address = result.Address, Phone = result.Phone, Email = result.Email, Birthday = result.Birthday }; customer.Order = O_repostiory.GetByAccountOfPresonOrder(Account).ToList(); foreach (var item in customer.Order) { item.details = OD_repostiory.GetByOrder_IDOfView(item.Order_ID).ToList(); } return(customer); }
public bool UpdateOrderDetail(Person_OrderDetail person_OrderDetail) { try { var products = RepositoryContainer.GetInstance <ProductsRepository>().GetByProduct_ID(person_OrderDetail.Product_ID); Order_DetailsRepository.Update(new Models.Order_Details { Order_Details_ID = person_OrderDetail.Order_Details_ID, Color = person_OrderDetail.Color, Product_ID = person_OrderDetail.Product_ID, Price = products.UnitPrice * person_OrderDetail.Quantity, Quantity = person_OrderDetail.Quantity, size = person_OrderDetail.size, }); var order_ID = Order_DetailsRepository.GetByOrder_Details_ID(person_OrderDetail.Order_Details_ID).Order_ID; var o = RepositoryContainer.GetInstance <OrdersRepository>(); o.UpdateTotalMoney(order_ID); return(true); } catch { return(false); } }
public IEnumerable <Customers> GetAll() { return(RepositoryContainer.GetInstance <CustomerRepository>().GetAll()); }
public IEnumerable <StockDetail> GetAll() { return(RepositoryContainer.GetInstance <StockRepository>().GetAllOfBackStage()); }