Ejemplo n.º 1
0
        public ActionResult AddCoursesToCart(int CourseId)
        {
            Session["CourseId"] = CourseId;
            EnrollRepo EnrRepo = new EnrollRepo();

            if (Session["cart"] == null)
            {
                List <EnrollModel> cart = new List <EnrollModel>();
                var product             = EnrRepo.GetAllCourseEnrollRepo().Find(enroll => enroll.courseId == CourseId);
                cart.Add(new EnrollModel()
                {
                    Product  = product,
                    Quantity = 1
                });
                Session["cart"] = cart;
            }
            else
            {
                List <EnrollModel> cart = (List <EnrollModel>)Session["cart"];
                var product             = EnrRepo.GetAllCourseEnrollRepo().Find(enroll => enroll.courseId == CourseId);
                if (cart.Count == 0)
                {
                    cart.Add(new EnrollModel()
                    {
                        Product  = product,
                        Quantity = 1
                    });
                }
                else
                {
                    foreach (var item in cart)
                    {
                        if (item.Product.courseId == CourseId)
                        {
                            cart.Remove(item);
                            cart.Add(new EnrollModel()
                            {
                                Product  = product,
                                Quantity = 1
                            });
                            break;
                        }
                        else
                        {
                            cart.Add(new EnrollModel()
                            {
                                Product  = product,
                                Quantity = 1
                            });
                            break;
                        }
                    }
                }
                Session["cart"] = cart;
            }
            return(RedirectToAction("CheckoutDetails"));
        }
Ejemplo n.º 2
0
 public ActionResult AddEnrollDetails(int id)
 {
     if (Session["UserId"] != null && Session["Accountid"] != null)
     {
         EnrollRepo EnrRepo = new EnrollRepo();
         return(View(EnrRepo.GetAllCourseEnrollRepo().Find(enroll => enroll.courseId == id)));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
Ejemplo n.º 3
0
 public ActionResult GetAllCourseEnroll()
 {
     if (Session["UserId"] != null && Session["Accountid"] != null)
     {
         EnrollRepo ep = new EnrollRepo();
         return(View(ep.GetAllCourseEnrollRepo()));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }