public JsonResult getDetail(string id) { var model = new CMS_OrderModels(); try { model = _fac.GetDetailOrder(id); if (model != null) { model.sCreatedDate = model.CreatedDate.ToString("dd/MM/yyyy hh:mm tt"); } } catch (Exception ex) { NSLog.Logger.Error("getDetail_Order:", ex); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult LoadOrderDetail(string OrderID) { try { var model = new CMS_OrderModels(); model = _facOrder.GetDetailOrder(OrderID); return(PartialView("_OrderDetail", model)); } catch (Exception ex) { NSLog.Logger.Error("GetOrderDetail", ex); return(new HttpStatusCodeResult(400, ex.Message)); } }
public ActionResult CheckOut(CMS_CheckOutModels model) { try { var _Orders = GetListOrderCookie(); NSLog.Logger.Info("List Order Cookie", JsonConvert.SerializeObject(_Orders)); if (_Orders != null && _Orders.Any()) { var ItemIds = _Orders.Select(x => x.ItemId).ToList(); var data = _fac.GetList().Where(o => ItemIds.Contains(o.Id)) .Select(o => new CMS_ItemModels { Price = o.ProductPrice, ProductID = o.Id, ProductName = o.ProductName, Quantity = o.Quantity }).ToList(); if (data != null && data.Any()) { data.ForEach(o => { var item = _Orders.FirstOrDefault(z => z.ItemId.Equals(o.ProductID)); o.Quantity = item.Quantity; o.TotalPrice = Convert.ToDouble(o.Price * item.Quantity); }); model.ListItem = data; model.TotalPrice = data.Sum(o => o.TotalPrice); model.SubTotalPrice = data.Sum(o => o.TotalPrice); if (!string.IsNullOrEmpty(model.DiscountID)) { model.ListItem.Add(new CMS_ItemModels { DiscountID = model.DiscountID, DiscountType = model.DiscountType, DiscountValue = model.DiscountValue }); if (model.DiscountType == (byte)CMS_Common.Commons.EValueType.Percent) { model.TotalDiscount = CommonHelper.RoundingOption4(model.TotalPrice * (model.DiscountValue / 100)); } else { model.TotalDiscount = model.DiscountValue; } model.TotalPrice = CommonHelper.RoundingOption4(model.TotalPrice - model.TotalDiscount); } } var OrderId = string.Empty; var result = _facOrder.CreateOrder(model, ref OrderId); if (result) { //get info order if (!string.IsNullOrEmpty(OrderId)) { var modelOrder = new CMS_OrderModels(); modelOrder = _facOrder.GetDetailOrder(OrderId); //body mail var body = CommonHelper.CreateBodyMail(modelOrder); var subject = "[V/v đơn hàng " + modelOrder.OrderNo + "]"; //Send to admin CommonHelper.SendContentMail(ConfigurationManager.AppSettings["LamodeMail"], body, "", subject, "", ""); //Send to customer CommonHelper.SendContentMail(modelOrder.Email, body, "", subject, "", ""); } HttpCookie currentUserCookie = HttpContext.Request.Cookies["cms-order"]; HttpContext.Response.Cookies.Remove("cms-order"); currentUserCookie.Expires = DateTime.Now.AddDays(-10); currentUserCookie.Value = null; HttpContext.Response.SetCookie(currentUserCookie); return(RedirectToAction("Index", "Home")); } else { model.IsError = true; } } } catch (Exception ex) { NSLog.Logger.Error("CheckOut", ex); } return(View(model)); }