public void AcceptOrder(int orderId) { var order = OrderRep.Get(orderId); var prodAccept = order.Products; var warehouse = LocationRep.Get(order.LocationId); foreach (var item in prodAccept) { var prod = warehouse.Products.Where(p => p.Product.ProductId == item.Product.ProductId).FirstOrDefault(); if (prod != null) { prod.Value += item.Value; prod.TotalQuantity += (decimal)item.Value; prod.TotalPrice += item.Price * (decimal)item.Value; prod.Price = prod.TotalPrice / prod.TotalQuantity; } else { warehouse.Products.Add ( new ProductStorage { Product = ProductRep.Get(item.Product.ProductId), Value = item.Value, Price = item.Price }); } } order.Accept = true; order.AcceptDate = DateTime.Today; }
public ActionResult Pay(Invoice model, List <string> PaymentTypes) { model.PaymentDate = DateTime.Now; foreach (string item in PaymentTypes) { int PaymentId = Convert.ToInt32(item); model.PaymentTypeId = PaymentId; } model.OrderId = ((Order)Session["Order"]).OrderId; InvoiceRep ip = new InvoiceRep(); if (ip.Insert(model).IsSuccessed) { List <Product> proList = new List <Product>(); Order ord = (Order)Session["Order"]; OrderRep ordrep = new OrderRep(); OrderDetailRep ordDetRep = new OrderDetailRep(); ProductRep proRep = new ProductRep(); Result <List <OrderDetail> > ordDetRes = ordDetRep.GetListByOrdId((int)model.OrderId); foreach (OrderDetail item in ordDetRes.ProcessResult) { Product pr = proRep.GetObjById(item.ProductId).ProcessResult; if (pr.Stock != null) { if (pr.Stock < item.Quantity) { string msg = "Yeterli sayida stok yok"; return(RedirectToAction("DetailList", "Order", new { msg = msg })); } else { pr.Stock -= item.Quantity; proList.Add(pr); } } } Member mem = (Member)Session["UserID"]; if (mem != null) { ord.MemberId = mem.UserId; ord.IsPay = true; ordrep.Update(ord); foreach (Product item in proList) { proRep.Update(item); } Session["Order"] = null; return(RedirectToAction("LatestOrders", "Home")); } else { return(RedirectToAction("SignIn", "Home")); } } else { return(View(model)); } }
public WorkOrderController() { ProductRep productRep = new ProductRep(); listProduct = productRep.GetAll(); MapperWorkOrder = new MapperWorkOrder(); repWorkOrder = new WorkOrderRep(); }
public int CheckStock(int id, int quantity) { ProductRep pr = new ProductRep(); Product p = pr.GetObjById(id).ProcessResult; if (p.Stock != null) { if (p.Stock < quantity || p.Stock < 0) { return(0); } } return(1); }
public ProductController() { mapperProduct = new MapperProduct(); repProduct = new ProductRep(); }
//Phương thức khởi tạo public ProductSvc() { _rep = new ProductRep(); }
public void CreateProduct(Product product, int UnitId, int ProductCategoryId) { product.Unit = UnitRep.Get(UnitId); product.ProductCategory = ProductCategoryRep.Get(ProductCategoryId); ProductRep.Add(product); }