Ejemplo n.º 1
0
 public bool add(SaleProductsDetails SaleProductsDetails)
 {
     return(_saleProductsDetailDal.add(SaleProductsDetails));
 }
Ejemplo n.º 2
0
 public bool update(SaleProductsDetails SaleProductsDetails)
 {
     return(_saleProductsDetailDal.update(SaleProductsDetails));
 }
        public ActionResult checkout(Bills bill)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (Request.IsAuthenticated)
                    {
                        Guid orderCode = Guid.NewGuid();

                        card card = (card)HttpContext.Session["activeBasket"];
                        if (card != null)
                        {
                            bill.orderCode = orderCode;

                            bill.billDate = DateTime.Now;

                            bill.totalPrice = card.cardTotalPrice;
                            bill.status     = true;
                            ctx.billBll.add(bill);
                            SaleProducts sale = new SaleProducts
                            {
                                customerID  = ctx.userBll.getOneByEmail(User.Identity.Name).id,
                                date        = DateTime.Now,
                                totalAmount = card.cardTotalPrice,
                                payType     = bill.payType,
                                billID      = bill.id,
                                status      = true,
                                orderCode   = orderCode,
                                description = bill.description,
                                orderDate   = bill.orderDate
                            };

                            ctx.saleProductBll.add(sale);


                            foreach (var item in card.BasketItems)
                            {
                                SaleProductsDetails details = new SaleProductsDetails
                                {
                                    productID    = item.products.id,
                                    count        = item.count,
                                    productPrice = (decimal)item.products.price,
                                    amount       = item.totalPrice,
                                    SaleID       = sale.id,
                                    tax          = card.tax
                                };
                                ctx.saleProductsDetailBll.add(details);
                            }


                            HttpContext.Session["activeBasket"] = null;
                        }
                        return(RedirectToAction("success", "basket", new { orderCode = orderCode }));
                    }
                    else
                    {
                        return(RedirectToAction("login", "users"));
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("_error", e.Message));
            }
        }