public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = mySQLOrderService.Detail(id); var lstFlowersModel = new List <FlowersInOrderModel>(); foreach (var item in order.OrderDetails) { var flowerModel = new FlowersInOrderModel() { Id = item.Id, FlowerName = mySQLFlowerService.Detail(item.FlowerCode).Name, ImageUrl = mySQLFlowerService.Detail(item.FlowerCode).FlowerImages.OrderByDescending(s => s.CreatedAt).FirstOrDefault().ImageUrl, Quantity = item.Quantity, TotalPricePerFlower = item.Quantity * item.UnitPrice }; lstFlowersModel.Add(flowerModel); } ViewBag.ListFlowersInOrder = lstFlowersModel; if (order == null || order.IsDeleted()) { return(HttpNotFound()); } return(View(order)); }
// GET: Flowers/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Flower flower = mySQLFlowerService.Detail(id); if (flower == null || flower.IsDeleted()) { return(HttpNotFound()); } return(View(flower)); }
// GET: ProductCategories/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Category flowerCategory = mySQLCategoryService.Detail(id); if (flowerCategory == null || flowerCategory.IsDeleted()) { return(HttpNotFound()); } return(View(flowerCategory)); }
public ActionResult DisplayCartAfterCreateOrder(int?orderId) { var order = db.Orders.Find(orderId); if (order == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Not Found")); } //ViewBag.ListFlowers = mySQLFlowerService.GetList().Where(s => order.OrderDetails.Select(p => p.FlowerCode).Contains(s.Code)).ToList(); var lstFlowersModel = new List <FlowersInOrderModel>(); foreach (var item in order.OrderDetails) { var flowerModel = new FlowersInOrderModel() { FlowerName = mySQLFlowerService.Detail(item.FlowerCode).Name, ImageUrl = mySQLFlowerService.Detail(item.FlowerCode).FlowerImages.OrderByDescending(s => s.CreatedAt).FirstOrDefault().ImageUrl, Quantity = item.Quantity, TotalPricePerFlower = item.Quantity * item.UnitPrice }; lstFlowersModel.Add(flowerModel); } ViewBag.ListFlowersInOrder = lstFlowersModel; // Paypal //bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]); //var paypal = new PayPalModel(useSandbox); ////Session[CurrentOrder] = order; //paypal.item_name = "Order of " + userService.GetCurrentUserName(); //paypal.amount = order.TotalPrice.ToString(); //var strParam = orderId + "," + userService.GetCurrentUserName() + "," + userService.GetCurrentUserId(); //paypal.notify_url = paypal.notify_url + "?strParam=" + strParam; //paypal.@return = paypal.@return + "?orderId=" + orderId; //paypal.cancel_return = paypal.cancel_return + "?orderId=" + orderId; //ViewBag.Paypal = paypal; return(View(order)); }
public ActionResult IndexCustomer(string amount, string sortFlower, string levelOneCategoryCode, string categoryCode, string searchString, string currentFilter, int?page, string searchFlowerGlobal, string filter) { if (!string.IsNullOrEmpty(filter)) { var filterThisPage = JsonConvert.DeserializeObject <ThisPage>(filter); if (string.IsNullOrEmpty(searchString)) { currentFilter = filterThisPage.SearchString; } if (string.IsNullOrEmpty(amount)) { amount = filterThisPage.Amount; } if (string.IsNullOrEmpty(sortFlower)) { sortFlower = filterThisPage.SortFlower; } if (string.IsNullOrEmpty(searchFlowerGlobal)) { searchFlowerGlobal = filterThisPage.SearchFlowerGlobal; } } if (string.IsNullOrEmpty(levelOneCategoryCode) && string.IsNullOrEmpty(categoryCode) && string.IsNullOrEmpty(searchFlowerGlobal)) { return(RedirectToAction("Index", "Home")); } ViewBag.CurrentUserName = userService.GetCurrentUserName(); if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; var flowers = mySQLFlowerService.GetList(); if (!String.IsNullOrEmpty(levelOneCategoryCode)) { var categories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode); flowers = categories.SelectMany(s => s.Flowers).Where(s => s.Status == Flower.FlowerStatus.NotDeleted).ToList(); ViewBag.Categories = categories; //categoryCode = categories.FirstOrDefault().Code; } if (!String.IsNullOrEmpty(categoryCode)) { flowers = flowers.Where(s => s.CategoryCode == categoryCode); var category = mySQLCategoryService.Detail(categoryCode); ViewBag.Categories = mySQLCategoryService.GetList().Where(s => s.ParentCode == category.ParentCode); //var productCategory = mySQLCategoryService.Detail(categoryCode); //var list = productCategory.OwnerOfCourses.ToList(); //ViewBag.Teachers = list; } if (!String.IsNullOrEmpty(searchFlowerGlobal)) { flowers = flowers.Where(s => s.Name.ToUpper().Contains(searchFlowerGlobal.ToUpper()) || s.Code.ToUpper().Contains(searchFlowerGlobal.ToUpper())); } ViewBag.CurrentFilterFlowerGlobal = searchFlowerGlobal; if (!String.IsNullOrEmpty(searchString)) { flowers = flowers.Where(s => s.Name.ToUpper().Contains(searchString.ToUpper()) || s.Code.ToUpper().Contains(searchString.ToUpper())); } if (!String.IsNullOrEmpty(sortFlower)) { switch (sortFlower) { case "1": flowers = flowers.OrderBy(s => s.Name); break; case "2": flowers = flowers.OrderBy(s => Utility.NewPrice(s.Price, s.Discount)); break; default: break; } if (string.IsNullOrEmpty(searchFlowerGlobal)) { levelOneCategoryCode = GetLevelOneCategoryCode(flowers); var lstCategories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode); ViewBag.Categories = lstCategories; } } if (!String.IsNullOrEmpty(amount)) { //var culture = System.Globalization.CultureInfo.GetCultureInfo("vn"); var nbspace = "\u00A0"; var text = HttpUtility.HtmlDecode(HttpUtility.HtmlDecode(nbspace)); var newStrAmount = amount.Replace(",", string.Empty).Replace(" ", string.Empty).Replace(text, string.Empty); var arrCharDong = newStrAmount.Where(s => !char.IsDigit(s)).ToArray(); var amounts = newStrAmount.Replace(arrCharDong.FirstOrDefault(), ',').Split(','); amounts = amounts.Skip(1).ToArray(); var min = Double.Parse(amounts.First()); var max = Double.Parse(amounts.Last()); flowers = flowers.Where(s => Utility.NewPrice(s.Price, s.Discount) <= max && Utility.NewPrice(s.Price, s.Discount) >= min); if (string.IsNullOrEmpty(searchFlowerGlobal)) { levelOneCategoryCode = GetLevelOneCategoryCode(flowers); var lstCategories = mySQLCategoryService.GetList().Where(s => s.ParentCode == levelOneCategoryCode); ViewBag.Categories = lstCategories; } } int pageSize = Constant.PageSizeFlowersOnCustomerPage; int pageNumber = (page ?? 1); ThisPage thisPage = new ThisPage() { CurrentPage = pageNumber, TotalPage = Math.Ceiling((double)flowers.Count() / pageSize), ProductCategoryCode = categoryCode, LevelOneCategoryCode = levelOneCategoryCode, CurrentType = Constant.Customer, SearchString = searchString, Amount = amount, SortFlower = sortFlower, SearchFlowerGlobal = searchFlowerGlobal }; ViewBag.Page = thisPage; //var flowerCategories = new List<Category>(); //foreach(var item in flowers) //{ // var category = mySQLCategoryService.Detail(item.CategoryCode); // flowerCategories.Add(category); //} // nếu page == null thì lấy giá trị là 1, nếu không thì giá trị là page //return View(students.ToList().ToPagedList(pageNumber, pageSize)); var list = flowers.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList(); return(View(flowers.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList())); }