public ActionResult Edit(int id) { var result = _bs.GetBoxById(id); BoxDTO boxDTO = result.Result; if (boxDTO == null) { return(HttpNotFound()); } GetViewBagData(); return(View("Edit", boxDTO)); }
//Sepetteki kutuların bilgilerini gösterir public ActionResult ShoppingCardDetail() { List <BoxDTO> boxes = new List <BoxDTO>(); var boxIDs = ((List <OrderDetailDTO>)Session["cartDetails"]).Select(x => x.BoxID).ToList(); foreach (var boxID in boxIDs) { try { var serviceResult = _bs.GetBoxById(boxID); if (serviceResult.State == ProcessStateEnum.Success) { boxes.Add(serviceResult.Result); } else { return(Content("Bir Hata Oluştu!")); } } catch (Exception ex) { return(Content(ex.Message)); } } return(View(boxes)); }
public object AddBoxToBasket(int BoxID) { object JsonData = null; var box = _bs.GetBoxById(BoxID); var selectedBox = ((List <OrderDetailDTO>)HttpContext.Current.Session["cartDetails"]).Where(x => x.BoxID == BoxID).FirstOrDefault(); //Sepette verilen id ye göre olan kutu getirilir if (selectedBox != null) //O kutu sepete atıldıysa işlem yapılmaz { JsonData = new { message = " isimli ürün mevcut sayı arttırmak ıcın sepetinize gidiniz", box = box.Result.BoxName }; } else //Sepette o kutu yoksa yeni bir OrderDetail oluşturularak bilgileri alınır. { var orderDetail = new OrderDetailDTO() { BoxID = box.Result.ID, BoxName = box.Result.BoxName, UnitPrice = box.Result.Price, ImageUrl = box.Result.ImageUrl, OrderDate = DateTime.Now }; ((List <OrderDetailDTO>)HttpContext.Current.Session["cartDetails"]).Add(orderDetail); JsonData = new { message = " isimli ürün sepete başarıyla eklenmiştir", box = box.Result.BoxName }; } return(JsonData); }
public ActionResult BoxesInBasket(FormCollection formColl) { for (int i = 0; i < formColl.Count / 2; i++) { int BoxID = Convert.ToInt32(formColl["shcartID-" + i + ""]); var box = _bs.GetBoxById(BoxID); foreach (var item in (List <OrderDetailDTO>)Session["cartDetails"]) { if (item.BoxID == BoxID) { item.BoxAmount = Convert.ToInt32(formColl["qty-" + i + ""]); item.TotalAmount = box.Result.Price * Convert.ToInt32(formColl["qty-" + i + ""]); var currentBox = ((List <OrderDetailDTO>)Session["cartDetails"]).Where(x => x.BoxID == BoxID).FirstOrDefault(); ((List <OrderDetailDTO>)Session["cartDetails"]).Where(x => x.BoxID == BoxID).FirstOrDefault().BoxAmount = Convert.ToInt32(formColl["qty-" + i + ""]); ((List <OrderDetailDTO>)Session["cartDetails"]).Where(x => x.BoxID == BoxID).FirstOrDefault().TotalAmount = currentBox.UnitPrice * Convert.ToInt32(formColl["qty-" + i + ""]); } } } return(RedirectToAction("Index", "CheckOut")); }