public ActionResult AddRestaurant(string key, string json, string code, Guid UserId, string port = ":4000") { try { if (key == Keyapi) { var obj = JsonConvert.DeserializeObject <OrderGetItem>(json); if (obj.list.Any()) { var listbed = _da.GetListArrId(obj.list); var order = new Shop_ContactOrder { StartDate = obj.StartDate, UserID = UserId, EndDate = obj.EndDate, DN_Bed_Desk1 = listbed, TotalMinute = obj.Value, AgencyId = Agencyid(), IsDelete = false, DateCreated = DateTime.Now.TotalSeconds(), CustomerID = obj.CustomerID, CustomerName = obj.CustomerName, Address = obj.Address, Discount = obj.Deposits, Mobile = obj.Mobile, IsEarly = obj.IsEarly, Status = (int)(int)FDI.CORE.OrderStatus.Pending, Content = HttpUtility.UrlDecode(obj.Note) }; _da.Add(order); _da.Save(); foreach (var jsonnew in obj.list.Select(item => new OrderProcessItem { ID = order.ID, BedDeskID = item, Minute = order.TotalMinute, StartDate = order.StartDate, EndDate = order.EndDate, AgencyId = Agencyid(), IsEarly = obj.IsEarly.HasValue && obj.IsEarly.Value, Status = 0 })) { json = new JavaScriptSerializer().Serialize(jsonnew); Node(port + "/addcontactorder/" + json); } return(Json(1, JsonRequestBehavior.AllowGet)); } } return(Json(0, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
public void Delete(Shop_ContactOrder item) { FDIDB.Shop_ContactOrder.Remove(item); }
public void Add(Shop_ContactOrder item) { FDIDB.Shop_ContactOrder.Add(item); }
public ActionResult Add(string key, string json, string code, Guid UserId, string port = ":3000") { try { if (key == Keyapi) { var obj = JsonConvert.DeserializeObject <ModelOrderGetItem>(json); var listcontact = new List <Shop_ContactOrder>(); foreach (var item in obj.list) { decimal totalprice = 0; var order = new Shop_ContactOrder { StartDate = obj.StartDate, UserID = UserId, EndDate = obj.EndDate, BedDeskID = item.idbed, TotalMinute = obj.Value, AgencyId = Agencyid(), IsDelete = false, DateCreated = DateTime.Now.TotalSeconds(), CustomerID = obj.CustomerID, CustomerName = obj.CustomerName, Address = obj.Address, Mobile = obj.Mobile, IsEarly = obj.IsEarly, Status = (int)(int)FDI.CORE.OrderStatus.Pending, Content = HttpUtility.UrlDecode(obj.Note) }; if (obj.Lstproduct != null) { var orderDetail = new Shop_ContactOrder_Details(); var lstp = obj.Lstproduct.Split(','); for (int i = 0; i < lstp.Length; i++) { var product = _da.GetProductItem(int.Parse(lstp[i])); totalprice += product.PriceNew; orderDetail = new Shop_ContactOrder_Details { ProductID = int.Parse(lstp[i]), Quantity = 1, Status = (int)(int)FDI.CORE.OrderStatus.Complete, Price = product.PriceNew, DateCreated = DateTime.Now.TotalSeconds(), }; order.Shop_ContactOrder_Details.Add(orderDetail); } order.TotalPrice = totalprice; } listcontact.Add(order); } foreach (var item in listcontact) { _da.Add(item); } _da.Save(); foreach (var jsonnew in listcontact.Select(item => new OrderProcessItem { ID = item.ID, BedDeskID = item.BedDeskID, Minute = item.TotalMinute, StartDate = item.StartDate, EndDate = item.EndDate, IsEarly = obj.IsEarly.HasValue && obj.IsEarly.Value, AgencyId = Agencyid(), Status = 0 })) { json = new JavaScriptSerializer().Serialize(jsonnew); Node(port + "/addcontactorder/" + json); } return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(0, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="aid">agencyid</param> /// <param name="cid">customerid</param> /// <param name="a">Địa chỉ người nhận</param> /// <param name="m">SĐT người nhận</param> /// <param name="json">Danh sách sản phẩm đặt.</param> /// <param name="la"></param> /// <param name="lo"></param> /// <returns></returns> public ActionResult AddContactOrder(string key, int id, int aid, int cid, string a, string m, string json, string la, string lo, string cn) { if (key == Keyapi) { try { if (!string.IsNullOrEmpty(json)) { var datenow = ConvertDate.TotalSeconds(DateTime.Now); var lst = GetObjJson <List <ContactDetaiAppItem> >(json); var lstDetail = lst.Where(item => item.Q > 0).Select(item => new Shop_ContactOrder_Details { GID = Guid.NewGuid(), Quantity = item.Q, QuantityOld = 0, Price = item.P, DateCreated = datenow, Status = (int)FDI.CORE.OrderStatus.Pending, ProductID = item.PId, }).ToList(); if (lstDetail.Any()) { var total = lstDetail.Sum(c => c.Price * c.Quantity); var totalQ = lstDetail.Sum(c => c.Quantity); var order = new Shop_ContactOrder { AgencyId = aid, Shop_ContactOrder_Details = lstDetail, TotalPrice = total, DateCreated = datenow, Status = (int)FDI.CORE.OrderStatus.Pending, IsDelete = false, StartDate = datenow, CustomerName = cn, Latitute = la, Longitude = lo, EndDate = datenow + 3600, CustomerID = cid, Mobile = m, Address = a, Quantity = totalQ }; if (id > 0) { order = _da.GetByID(id); order.Shop_ContactOrder_Details.Clear(); order.Shop_ContactOrder_Details = lstDetail; order.Address = a; order.Mobile = m; } else { _da.Add(order); } _da.Save(); return(Json(1, JsonRequestBehavior.AllowGet)); } } } catch (Exception) { } } return(Json(0, JsonRequestBehavior.AllowGet)); }
public ActionResult DoOrder(OrderGetItem model) { var customer = _customerDA.GetCustomerItem(CustomerId); var date = ConvertDate.TotalSeconds(DateTime.Now); var hour = 0; var orderType = model.ListProductModel.Select(m => (CORE.OrderType)m.OrderType).OrderBy(m => m.GetOrder()).FirstOrDefault(); var receive = DateTime.Today; if (orderType == CORE.OrderType.TOMORROW) { hour = 12; receive = receive.AddDays(1); } if (orderType == CORE.OrderType.BEFORE12H) { hour = 12; } if (orderType == CORE.OrderType.BEFORE17H) { hour = 17; } var order = new Shop_ContactOrder() { Address = model.Address, CustomerID = CustomerId, CustomerName = model.CustomerName, Mobile = model.Mobile, AgencyId = customer.AgencyId, Status = (int)FDI.CORE.OrderStatus.Pending, ReceiveDate = ConvertDate.TotalSeconds(receive), ReceiveHour = hour, DateCreated = date, IsDelete = false }; foreach (var productItem in model.ListProductModel) { var product = _productDa.GetProductDetailItem(productItem.ID); if (product == null) { return(Json(new JsonMessage(true, "Sản phẩm không tồn tại"))); } var day = OrderExtensions.GetDayByOrderType((OrderType)productItem.OrderType); var hours = OrderExtensions.GetHourByOrderType((OrderType)productItem.OrderType); var todayCode = ConvertDate.TotalSeconds(DateTime.Today.AddDays(day)); var receiveDate = ConvertDate.TotalSeconds(DateTime.Today.AddDays(day).AddHours(hours)); var productitem = new Shop_ContactOrder_Details() { Quantity = productItem.Q, ProductID = productItem.ID, Price = product.PriceUnit, //don gia Weight = productItem.Weight, DateCreated = date, OrderType = productItem.OrderType, TodayCode = todayCode, ReceiveDate = receiveDate, GID = Guid.NewGuid(), }; switch (productitem.OrderType) { case 1: productitem.DateCreated = ConvertDate.TotalSeconds(DateTime.Today.AddHours(12)); break; } order.Shop_ContactOrder_Details.Add(productitem); } order.TotalPrice = order.Shop_ContactOrder_Details.Sum(m => m.Price * m.Quantity * m.Weight); _orderDa.Add(order); _orderDa.Save(); return(Json(new JsonMessage(false, "Đặt hàng thành công"))); }