public IActionResult Detail(int id) { var setBox = _SetBoxService.GetById(id); var model = new SetBoxDetailModel() { Id = setBox.Id, ImageUrl = setBox.ImageUrl, Name = setBox.Name, Price = setBox.Price, Specification = setBox.Specification }; return(View(model)); }
public IActionResult MyPackage() { CustomerCard card = _cardService.GetCurrentUserCard(_userManager.GetUserId(HttpContext.User)); Package package = _packageService.GetById(card.Package.Id); SetBox SetBox = _sbService.GetById(card.SetBox.Id); Customer cus = _cusService.GetByUser(_userManager.GetUserId(HttpContext.User)); DateTime expire = _cpService.GetExpirationTime(cus.Id); CustomerPackage cp = _cpService.GetByCardId(card.Id); string status = UpdatePakageStatus(cp, expire); MyPackageViewModel model = new MyPackageViewModel { MyPackage = new PackageDetailViewModel { PackageName = package.PackageName, NoOfChannels = package.NoOfChannels, Charges = package.Charges, ImageUrl = package.ImageUrl }, MySetBox = new SetBoxDetailModel { Name = SetBox.Name, Specification = SetBox.Specification, Price = SetBox.Price, ImageUrl = SetBox.ImageUrl }, GetExpiration = expire, State = status }; return(View(model)); }
public IActionResult AddToCart(int Id, int qty) { List <CartItem> CartItems; var CartSession = HttpContext.Session.GetString("Cart"); Cart Cart; if (CartSession == null) { Cart = new Cart(); CartItems = new List <CartItem>(); } else { Cart = JsonConvert.DeserializeObject <Cart>(HttpContext.Session.GetString("Cart")); CartItems = Cart.ItemList; } SetBox sb = _setBoxService.GetById(Id); if (CartItems.Any(i => i.Product.Name == sb.Name)) { CartItems.SingleOrDefault(i => i.Id == Id).Qty += qty; CartItems.SingleOrDefault(i => i.Id == Id).Price += (qty * sb.Price); } else { CartItem item = new CartItem { Id = ++CartItemId, Product = sb, Qty = qty, Price = qty * sb.Price }; CartItems.Add(item); } Cart.ItemList = CartItems; Cart.TotalPrice = Cart.ItemList.Sum(m => m.Price); Cart.TotalItems = Cart.ItemList.Sum(m => m.Qty); HttpContext.Session.SetString("Cart", JsonConvert.SerializeObject(Cart)); return(RedirectToAction("Index")); }
public IActionResult Approved(int?Id) { if (Id == null) { return(NotFound()); } var request = _newSetBoxService.GetById(Id); if (request == null) { return(NotFound()); } CustomerCard card = _cardService.GetCardByNumber(request.Card.CardNumber); card.SetBox = _setboxService.GetById(request.Card.Id); _cardService.Update(card); request.Status = _statusService.GetByName("AdminApproved"); _newSetBoxService.Update(request); return(RedirectToAction("Index")); }
public IActionResult Index(SubscribeAddModel newSub) { SetDropDown(); if (ModelState.IsValid) { var model = newSub; _subService.AddSubscribe(new NewSubscribe() { OwnerName = model.OwnerName, Address = model.Address, ApplyDate = DateTime.Now, ContactNumber = model.ContactNumber, Package = _packageService.GetById(model.PackageId), SetBox = _setBoxService.GetById(model.SetBoxId), Status = _statusService.GetByName("Pending") }); ModelState.Clear(); ViewBag.success = "success"; ViewBag.msg = "Request Send Successfully, We will contact you soon"; return(View()); } return(View(newSub)); }