public static DataView GetStockOutReport(int orderId) { var query = HCMIS.Repository.Queries.OrderDetail.SelectStockOutDetail(orderId); var orderDetail = new OrderDetail(); orderDetail.LoadFromRawSql(query); return orderDetail.DefaultView; }
public static OrderDetail GenerateOrderDetail(int unitId, int activityId, decimal pack, int orderId, int qtyPerPack, int itemId) { var ord = new OrderDetail(); ord.LoadByItemUnit(orderId,itemId,unitId,activityId); if (ord.RowCount == 0) { ord.AddNew(); ord.OrderID = orderId; ord.ItemID = itemId; ord.UnitID = unitId; ord.StoreID = activityId; ord.Pack = pack; ord.QtyPerPack = qtyPerPack; ord.Quantity = pack*qtyPerPack; ord.ApprovedQuantity = pack*qtyPerPack; } else { ord.Pack += pack; ord.Quantity += pack; ord.ApprovedQuantity += pack*qtyPerPack; } ord.Save(); return ord; }
protected void btnSave_Click(object sender, EventArgs e) { Order o = new Order(); o.OrderNo = CreateOrderNo();// rastgele oluştur o.UserId = new Guid(Membership.GetUser().ProviderUserKey.ToString()); o.Date = DateTime.Now; OrderBLL ob = new OrderBLL(); ob.Add(o); ProductBLL pb = new ProductBLL(); foreach (var p in Helper.Sepet) { OrderDetail od = new OrderDetail(); od.OrderId = o.Id; od.ProductId = p.Id; od.Quantity = p.Quantity; OrderDetailBLL obll = new OrderDetailBLL(); obll.Add(od); Product pr = pb.Get(x => x.Id == p.Id).FirstOrDefault(); pr.Stock -= p.Quantity; pb.Update(pr); Helper.Sepet = new List<ProductDTO>(); } }
//Get order details public OrderDetail GetOrderDetail() { mergedEntities db = new mergedEntities(); OrderDetails repo = new OrderDetails(); OrderDetail order = new OrderDetail(); var query = from a in db.OrderDetails where (a.orderNumber == repo.OrderNumber) select new { OrderNumber = a.orderNumber, OrderDate = a.orderDate, Delivery = a.deliveryStatus, }; foreach (var item in query) { order.orderNumber = item.OrderNumber; order.orderDate = item.OrderDate; order.deliveryStatus = item.Delivery; } return order; }
void PopulateOrders () { if (App.CheckoutItems == null) { return; } var foodItems = App.CheckoutItems.GroupBy (p => p.Id); foreach (var item in foodItems) { var food = item.FirstOrDefault (); if (food == null) continue; var order = new OrderDetail { FoodId = food.Id, FoodName = food.Name, Quantity = item.Count (), SellingPrice = food.PricePerQty, }; CheckoutItems.Add (new OrderDetailsViewModel (order, this)); } if (CheckoutItems.Count <= 0) { return; } TotalPrice = CheckoutItems.Sum (p => p.Details.TotalPrice); }
public LoadReportForEditResponse(ReportDetail report, int reportPartIndex, OrderDetail order, List<EnumValueInfo> priorityChoices) { Report = report; ReportPartIndex = reportPartIndex; Order = order; PriorityChoices = priorityChoices; }
public int CreateOrder(Order order) { decimal orderTotal = 0; var cartItems = GetCartItems(); foreach (var item in cartItems) { var orderDetail = new OrderDetail { CarID = item.CarID, OrderID = order.OrderID, UnitPrice = item.Car.Price, Quantity = item.Count }; orderTotal += (item.Count*item.Car.Price); storeDB.OrderDetails.Add(orderDetail); } order.Total = orderTotal; storeDB.SaveChanges(); EmptyCart(); return order.OrderID; }
public ActionResult Purchase(Order model) { db.Orders.Add(model); var cart = ShoppingCart.Cart; foreach (var p in cart.Items) { var d = new OrderDetail { Order = model, ProductId = p.Id, UnitPrice = p.UnitPrice, Discount = p.Discount, Quantity = p.Quantity }; db.OrderDetails.Add(d); } db.SaveChanges(); // Thanh toán trực tuyến //var api = new WebApiClient<AccountInfo>(); //var data = new AccountInfo //{ // Id = Request["BankAccount"], // Balance = cart.Total //}; //api.Put("api/Bank/nn", data); return RedirectToAction("Detail", new { id = model.Id }); }
public ActionResult SaveBill(FormCollection frmData) { Orders od = new Orders(); Cart<Product> cart = HttpContext.Session["Cart"] as Cart<Product>; od.OrdersID = orders.NextID(); od.AccountID = 1; od.Adress = frmData["txtAddess"]; od.OrderDate = DateTime.Now; od.CMND = frmData["txtPassport"]; od.Email = frmData["txtEmail"]; od.FirstName = frmData["txtFName"]; od.LastName = frmData["txtLName"]; od.Note = frmData["txtNote"]; od.PhoneNumber = frmData["txtPhone"]; od.ReceiveAddress = frmData["txtReceive"]; od.Status = (int)OrderStatus.Pending; od.TotalAmount = cart.CalculateAmount(); for (int i = 0; i < cart.ListItems.Count;i++ ) { OrderDetail ordl = new OrderDetail(); ordl.OrderDetailID = orderDetail.NextID(); ordl.OrdersID = od.OrdersID; ordl.ProductID = cart.ListItems[i].Item.ProductID; ordl.Quantity = cart.ListItems[i].Quantity; ordl.Price = cart.ListItems[i].Item.ListedPrice*cart.ListItems[i].Quantity; _dObject.Insert(ordl); } _dObject.Insert(od); return Json("ok"); }
public void TestGetOrder() { Checkout checkout = new Checkout(); // checkout.BuerId =new Guid("2D3455F8-C7B5-4949-814A-A02A00DE271E"); checkout.PriceType = PriceType.PayOnline; List<OrderDetail> details = new List<OrderDetail>(); OrderDetail detail = new OrderDetail(); detail.Quantity =5; Ticket t = new BLLTicket().GetTicket(1); TicketPrice tp = t.TicketPrice.Single<TicketPrice>(x => x.PriceType == PriceType.PayOnline); detail.TicketPrice = tp; for (int i = 0; i < detail.Quantity; i++) { TicketAssign ta = new TicketAssign(); ta.IdCard = "idcard1"; ta.IsUsed = false; ta.Name = "namei"; detail.TicketAssignList.Add(ta); } // new BLLOrderDetail().SaveOrUpdateOrderDetail(detail); details.Add(detail); checkout.Details = details; checkout.MakeOrder(); }
public OrderDetailModel(OrderDetail detail) : this() { if (detail != null) ModelObjectHelper.CopyObject(detail, this); UrlName = StringHelper.VNSignedToLowerUnsigned(ItemName); }
public int CreateOrder(Order order) { decimal orderTotal = 0; var cartItems = GetCartItems(); // Iterate over the items in the cart, adding the order details for each foreach (var item in cartItems) { var orderDetail = new OrderDetail { ProductId = item.ProductId, OrderId = order.OrderId, UnitPrice = item.Product.Price, Quantity = item.Count }; // Set the order total of the shopping cart orderTotal += (item.Count * item.Product.Price); storeDB.OrderDetails.Add(orderDetail); } // Set the order's total to the orderTotal count order.Total = orderTotal; // Save the order storeDB.SaveChanges(); // Empty the shopping cart EmptyCart(); // Return the OrderId as the confirmation number return order.OrderId; }
public ActionResult Purchase(Order model) { try { db.Orders.Add(model); foreach (var p in ProjectMVC5.Models.ShoppingCart.Cart.Items) { var detail = new OrderDetail() { Order = model, ProductId = p.Id, Quantity = p.Quantity, UnitPrice = p.Price, }; db.OrderDetails.Add(detail); } db.SaveChanges(); ProjectMVC5.Models.ShoppingCart.Cart.clear(); return RedirectToAction("OrderList"); } catch { ModelState.AddModelError("", "Đặt hàng lỗi"); } return View("Checkout"); }
public Order BuildOrderForQZ(TourMembership member, string assignName, string idcardno, Ticket currentTicket, int amount, string parnterName) { #region 开始出票 //1 为身份证号创建一个用户名 TicketAssign ta = new TicketAssign(); ta.IdCard = idcardno; ta.IsUsed = false; ta.Name = assignName; OrderDetail orderdetail = new OrderDetail(); orderdetail.Quantity = amount; orderdetail.Remark = "衢州新春门票派送活动自动创建订单,请票来源:" + parnterName; orderdetail.TicketAssignList.Add(ta); TicketPrice ticketPrice = currentTicket.GetTicketPrice(PriceType.PayOnline); orderdetail.TicketPrice = ticketPrice; Order order = new Order(); order.BuyTime = DateTime.Now; order.IsPaid = true; order.TourMembership = member; order.OrderDetail.Add(orderdetail); order.PayTime = DateTime.Now; order.PriceType = PriceType.PayOnline; order.PayTime = DateTime.Now; order.TradeNo = "QZFREE"; return order; #endregion }
/// <summary> /// Maps arrary of order detail data transfer objects to list of order details models. /// </summary> /// <param name="orderDetails">Array of order detail data transfer objects.</param> /// <returns>List of order detail models.</returns> internal static IList<OrderDetailModel> FromDataTransferObjects(OrderDetail[] orderDetails) { if (orderDetails == null) return null; return orderDetails.Select(FromDataTransferObject).ToList(); }
public void Test_AddOrderDetails() { IOC.RegisterComponents(); Order order = Repository<Order>.All(this).First(); Product product = Repository<Product>.All(this).First(); OrderDetail ordDetail = new OrderDetail() { Discount = 0, Quantity = 1, ParentOrder = order, ParentProduct = product }; Repository<OrderDetail>.Save(ordDetail, this); }
public static OrderDetail AssembleOrderDetail(DomainModel.OrderDetail detail) { OrderDetail dto = new OrderDetail(); dto.ProductId = (int)detail.Product.Id[0]; dto.Quantity = detail.Quantity; dto.UnitPrice = detail.UnitPrice; dto.Timestamp = detail.Timestamp.Value; return dto; }
public void GetLineTotalCalculatesTotal() { short quantity = 3; decimal unitPrice = 12.23m; OrderDetail detail = new OrderDetail(1, 1, quantity, unitPrice); decimal total = detail.LineTotal; Assert.AreEqual((decimal)(quantity * unitPrice), total); }
/// <summary> /// Maps order detail data transfer object to order model object. /// </summary> /// <param name="orderDetail">Order detail data transfer object.</param> /// <returns>Orderdetail model object.</returns> internal static OrderDetailModel FromDataTransferObject(OrderDetail orderDetail) { return new OrderDetailModel { ProductName = orderDetail.ProductName, Discount = orderDetail.Discount, Quantity = orderDetail.Quantity, UnitPrice = orderDetail.UnitPrice, Version = orderDetail.Version }; }
public void GetOrderTotalCalculatesTotal() { Order order = new Order(); OrderDetail line1 = new OrderDetail(1, 1, 2, 2.35m); OrderDetail line2 = new OrderDetail(1, 1, 1, 1.09m); order.Details.Add(line1); order.Details.Add(line2); decimal total = order.OrderTotal; Assert.AreEqual((decimal)(line1.LineTotal + line2.LineTotal), total); }
internal static BL.DomainModel.OrderDetail AdaptOrderDetail(OrderDetail d) { BL.DomainModel.OrderDetail orderDetail = new BL.DomainModel.OrderDetail() { OrderDetailId = d.OrderDetailId, QuantityInUnits = d.QuantityInUnits, UnitPrice = d.UnitPrice, Version = d.Version.ToUlong(), Product = ProductAdapter.AdaptProduct(d.Product) }; return orderDetail; }
public void InsertOrUpdate(OrderDetail orderdetail) { if (orderdetail.Id == default(int)) { // New entity context.OrderDetails.Add(orderdetail); } else { // Existing entity context.Entry(orderdetail).State = EntityState.Modified; } }
protected void Page_Load(object sender, EventArgs e) { int id = 0; if (int.TryParse(Request.QueryString["id"], out id)) { od = OrderDetailOperation.GetOrderDetailById(id); order = OrderOperation.GetOrderById(od.OrderId); } if (!IsPostBack) { FormDataBind(); } }
internal static BL.DomainModel.OrderDetail AdaptOrderDetail(OrderDetail d, BL.DomainModel.Order o) { BL.DomainModel.OrderDetail orderDetail = new BL.DomainModel.OrderDetail() { OrderDetailId = d.OrderDetailId, QuantityInUnits = d.QuantityInUnits, UnitPrice = d.UnitPrice, Version = d.Version.ToUlong(), Order = (o == null) ? AdaptOrder(d.OrderReference) : o, Product = ProductAdapter.AdaptProduct(d.ProductReference) }; return orderDetail; }
public static bool InsertOrder(OrderBase orderBase, OrderDetail detail) { try { orderBase = orderBase.PostAdd(); detail.OrderID = orderBase.ID; detail = detail.PostAdd(); if (orderBase.ID != null && detail.ID != null) return true; else return false; } catch (Exception ex) { LogHelper.Write(CommonLogger.Application, ex); return false; } }
protected void btnOrder_Click(object sender, EventArgs e) { using(DBDataContext db = new DBDataContext()) { CartResponse cr = new CartResponse(); Order o = new Order() { Appartmant = txtAppartment.Text.Trim(), Building = txtBuilding.Text.Trim(), City = txtCity.Text.Trim(), Comments = txtComment.Text.Trim(), CreatedOn = DateTime.Now, DeliveryCost = cr.delivery, Email = txtEmail.Text.Trim(), Name = txtName.Text.Trim(), Phone = txtPhone.Text.Trim(), Pnone2 = txtPhone2.Text.Trim(), Status = (int)OrderStatus.ZAKAZAN, Street = txtStreet.Text.Trim(), }; db.Orders.InsertOnSubmit(o); db.SubmitChanges(); Cart cart = Cart.GetCurrentCart(); foreach (CartItem ci in cart.Items) { Item itm = db.Items.First(I=>I.ID == ci.ItemID); OrderDetail od = new OrderDetail() { ItemID = ci.ItemID, ItemCount = ci.ItemCount, Order = o, PricePerItem = itm.TotalPrice }; db.OrderDetails.InsertOnSubmit(od); } db.SubmitChanges(); SMSManager.SendSMSV2ToUser(o.Phone, o.ID, (cr.price + cr.delivery)); SMSManager.SendSMSV2ToAdmin(o.Phone, o.Name, o.ID, cr.count, cr.price); cart.ClearCart(); } Response.Redirect(ResolveUrl("~/CartPage.aspx?accepted=1")); }
public ActionResult AddOrder() { string userName = System.Web.HttpContext.Current.User.Identity.Name; if (userName != null && userName != "") { OrderBase orderBase = new OrderBase(); orderBase.CreateTime = DateTime.Now; orderBase.CreaterUser = userName; orderBase.TransferAccountNumber = Request["transferAccountNumber"].ToString(); orderBase.TransferAccountTime = DateTime.ParseExact(Request["transferAccountTime"],"yyyy-MM-dd HH:mm", CultureInfo.CurrentCulture); orderBase.TransferMethod = Request["transferMethod"].ToString(); orderBase.TransferredAmount = Convert.ToDecimal(Request["transferAmount"].ToString()); orderBase.BeneficiaryAccountNo = Request["beneficiaryAccountNo"].ToString(); orderBase.Comments = Request["comments"].ToString(); orderBase.Source = Request["source"].ToString(); orderBase.PayerName = userName; OrderDetail orderDetail = new OrderDetail(); //orderDetail.OrderID = orderBase.ID; orderDetail.ProductName = Request["productName"].ToString(); orderDetail.Numbers = Convert.ToInt32(Request["ProductAccount"].ToString()); orderDetail.UnitPrice = Convert.ToDecimal(Request["originPrice"].ToString()); orderDetail.TotalPrice = Convert.ToDecimal(Request["totalPrice"].ToString()); orderDetail.PayTime = DateTime.ParseExact(Request["payTime"], "yyyy-MM-dd HH:mm", CultureInfo.CurrentCulture); orderDetail.PayAccount = Request["payAccount"].ToString(); orderDetail.GoldAccount = Convert.ToInt64(Request["goldAccount"].ToString()); //orderDetail.PayDeviceAccount = Request["payDeviceAccount"].ToString(); orderDetail.Pay4PlayerId =Convert.ToInt64(Request["pay4PlayerId"].ToString()); bool insertStatus = PlaceOrderBiz.InsertOrder(orderBase, orderDetail); if (insertStatus) return Content("1"); else return Content("0"); } else { return Content("0"); } }
// note that this viewmodel is instantiated on-demand from parent and not with DI public EditOrderDetailViewModel(IServiceFactory serviceFactory, OrderDetail orderDetail) { _serviceFactory = serviceFactory; _orderDetail = new OrderDetail() { Id = orderDetail.Id, Notes = orderDetail.Notes, Count = orderDetail.Count, //ToDo Part = OrderId = orderDetail.OrderId, Price = orderDetail.Price }; _orderDetail.CleanAll(); LoadParts(); SaveCommand = new DelegateCommand<object>(OnSaveCommandExecute, OnSaveCommandCanExecute); CancelCommand = new DelegateCommand<object>(OnCancelCommandExecute); }
protected void btnAdd_Click(object sender, EventArgs e) { if (IsValid) { try { Service service = SB.GetService(ddlService.Text); OrderDetail orderDetail = new OrderDetail(); orderDetail.Service_Id = service.Service_Id; orderDetail.Service_Name = service.Service_Name; orderDetail.Service_Image = service.Service_Image; orderDetail.OrderOfServiceDetail_FromDate = txtFromDate.Text.Trim(); orderDetail.OrderOfServiceDetail_ToDate = txtToDate.Text.Trim(); orderDetail.OrderOfServiceDetail_NumberOfEmployee = Int32.Parse(txtNumberEmployee.Text.Trim()); DateTime toDate = DateTime.Parse(orderDetail.OrderOfServiceDetail_ToDate); DateTime fromDate = DateTime.Parse(orderDetail.OrderOfServiceDetail_FromDate); double days = (toDate - fromDate).TotalDays; double charge = Double.Parse(SecurityHelper.Instance.DecryptCryptography(service.Service_Charge, true)); int employee = orderDetail.OrderOfServiceDetail_NumberOfEmployee; double price = days * charge * employee; orderDetail.OrderOfServiceDetail_Price = ToCurrency(price); List<OrderDetail> listOrderDetail = (List<OrderDetail>)Session["listOrderDetailModify"]; listOrderDetail.Add(orderDetail); grvManage.DataSource = listOrderDetail; grvManage.DataBind(); ddlService.SelectedIndex = 0; ResetForm(); ResetPanel(); } catch (Exception ex) { pnlRed.Visible = true; lblError.Text = ex.Message; hplnkRed.Text = "Please try again."; hplnkRed.NavigateUrl = ""; } } }
public ActionResult Index(OrderViewModel order) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Please fix error before proceeding!"); return View(order); } Order _order = new Order(); _order.OrderDate = DateTime.Today.Date; _order.Username = System.Web.HttpContext.Current.Session["USER_NAME"].ToString(); _order.FirstName = order.FirstName; _order.LastName = order.LastName; _order.Address = order.Address; _order.City = order.City; _order.State = order.State; _order.PostalCode = order.PostalCode; _order.Country = order.Country; _order.Email = order.Email; _order.Phone = order.Phone; _order.HasBeenShipped = false; _order.Total = order.Total; _repository.AddOrder(_order); var _shoppingCartDetails = _repository.GetShoppingCartDetails(); for (int i = 0; i < _shoppingCartDetails.Count; i++) { OrderDetail _orderDetails = new OrderDetail(); _orderDetails.OrderId = _order.OrderId; _orderDetails.Username = System.Web.HttpContext.Current.Session["USER_NAME"].ToString(); _orderDetails.ProductId = _shoppingCartDetails[i].ProductID; _orderDetails.Quantity = _shoppingCartDetails[i].Quantity; _orderDetails.UnitPrice = _shoppingCartDetails[i].Price; _repository.AddOrderDetails(_orderDetails); } return RedirectToAction("ReviewOrder", new { orderID = _order.OrderId }); }
public static Response NewOrder(NewOrderView view, string userName) { using (var transaccion = db.Database.BeginTransaction()) { try { var user = db.Users.Where(u => u.UserName == userName).FirstOrDefault(); var order = new Order { CompanyId = user.CompanyId, CustomerId = view.CustomerId, Date = view.Date, Remarks = view.Remarks, StateId = DBHelper.GetState("Created", db), }; db.Orders.Add(order); db.SaveChanges(); var details = db.OrderDetailTmps.Where(odt => odt.UserName == userName).ToList(); foreach (var detail in details) { var orderDetail = new OrderDetail { Description = detail.Description, OrderId = order.OrderId, Price = detail.Price, ProductId = detail.ProductId, Quantity = detail.Quantity, TaxRate = detail.TaxRate, }; db.OrderDetails.Add(orderDetail); db.OrderDetailTmps.Remove(detail); } db.SaveChanges(); transaccion.Commit(); return(new Response { Succeeded = true }); } catch (Exception ex) { transaccion.Rollback(); if (ex.InnerException != null && ex.InnerException.InnerException != null) { return(new Response { Succeeded = false, Message = ex.InnerException.InnerException.Message }); } else if (ex.InnerException != null) { return(new Response { Succeeded = false, Message = ex.InnerException.Message }); } else { return(new Response { Succeeded = false, Message = ex.Message }); } } } }
public static Models.Repository.OrderDetail CreateDtoOrderDetail(this OrderDetail order) { return(new Models.Repository.OrderDetail { }); }
private bool ValidateInput(OrderDetail order) { return(true); }
private List <Order> CreateTestOrders(NorthwindDbContext context) { // Create test entities var category1 = new Category { CategoryName = "Test Category 1" }; var category2 = new Category { CategoryName = "Test Category 2" }; var product1 = new Product { ProductName = "Test Product 1", UnitPrice = 10M, Category = category1 }; var product2 = new Product { ProductName = "Test Product 2", UnitPrice = 20M, Category = category2 }; var product3 = new Product { ProductName = "Test Product 3", UnitPrice = 30M, Category = category2 }; var customer1 = context.Customers .Include(c => c.Territory) .Include(c => c.CustomerSetting) .Single(c => c.CustomerId == TestCustomerId1); var customer2 = context.Customers .Include(c => c.Territory) .Include(c => c.CustomerSetting) .Single(c => c.CustomerId == TestCustomerId1); var detail1 = new OrderDetail { Product = product1, Quantity = 11, UnitPrice = 11M }; var detail2 = new OrderDetail { Product = product2, Quantity = 12, UnitPrice = 12M }; var detail3 = new OrderDetail { Product = product2, Quantity = 13, UnitPrice = 13M }; var detail4 = new OrderDetail { Product = product3, Quantity = 14, UnitPrice = 14M }; var order1 = new Order { OrderDate = DateTime.Today, Customer = customer1, OrderDetails = new List <OrderDetail> { detail1, detail2, } }; var order2 = new Order { OrderDate = DateTime.Today, Customer = customer2, OrderDetails = new List <OrderDetail> { detail3, detail4, } }; // Persist entities context.Orders.Add(order1); context.Orders.Add(order2); context.SaveChanges(); // Detach entities var objContext = ((IObjectContextAdapter)context).ObjectContext; objContext.Detach(order1); objContext.Detach(order2); // Clear reference properties product1.Category = null; product2.Category = null; product3.Category = null; customer1.Territory = null; customer2.Territory = null; customer1.CustomerSetting = null; customer2.CustomerSetting = null; detail1.Product = null; detail2.Product = null; detail3.Product = null; detail4.Product = null; order1.OrderDetails = new List <OrderDetail> { detail1, detail2 }; order2.OrderDetails = new List <OrderDetail> { detail3, detail4 }; // Return orders return(new List <Order> { order1, order2 }); }
public ActionResult CreateOrder(string orderViewModel) { var order = new JavaScriptSerializer().Deserialize <OrderViewModel>(orderViewModel); var orderNew = new Order(); orderNew.UpdateOrder(order); if (Request.IsAuthenticated) { orderNew.CustomerId = User.Identity.GetUserId(); orderNew.CreatedBy = User.Identity.GetUserName(); } var cart = (List <ShoppingCartViewModel>)Session[CommonConstants.SessionCart]; List <OrderDetail> orderDetails = new List <OrderDetail>(); bool isEnough = true; foreach (var item in cart) { var detail = new OrderDetail(); detail.ProductID = item.ProductId; detail.Quantity = item.Quantity; detail.Price = item.Product.Price; orderDetails.Add(detail); isEnough = _productService.SellProduct(item.ProductId, item.Quantity); break; } if (isEnough) { var orderReturn = _orderService.Create(ref orderNew, orderDetails); _productService.Save(); if (order.PaymentMethod == "CASH") { return(Json(new { status = true })); } else { var currentLink = ConfigHelper.GetByKey("CurrentLink"); RequestInfo info = new RequestInfo(); info.Merchant_id = merchantId; info.Merchant_password = merchantPassword; info.Receiver_email = merchantEmail; info.cur_code = "vnd"; info.bank_code = order.BankCode; info.Order_code = orderReturn.ID.ToString(); info.Total_amount = orderDetails.Sum(x => x.Quantity * x.Price).ToString(); info.fee_shipping = "0"; info.Discount_amount = "0"; info.order_description = "Thanh toán đơn hàng tại ShopOnline"; info.return_url = currentLink + "xac-nhan-don-hang.html"; info.cancel_url = currentLink + "huy-don-hang.html"; info.Buyer_fullname = order.CustomerName; info.Buyer_email = order.CustomerEmail; info.Buyer_mobile = order.CustomerMobile; APICheckoutV3 objNLChecout = new APICheckoutV3(); ResponseInfo result = objNLChecout.GetUrlCheckout(info, order.PaymentMethod); if (result.Error_code == "00") { return(Json(new { status = true, urlCheckout = result.Checkout_url, message = result.Description })); } else { return(Json(new { status = false, message = result.Description })); } } } else { return(Json(new { status = false, message = "Không đủ hàng." })); } }
protected override void Seed(project_sem_3.Models.ApplicationDbContext context) { // role context.Roles.AddOrUpdate(x => x.Id, new ApplicationRole() { Id = "1", Name = "Super" }, new ApplicationRole() { Id = "2", Name = "Admin" } //new ApplicationRole() { Id = "3", Name = "User" } ); // user var passwordHash = new PasswordHasher(); string password = passwordHash.HashPassword("@Ad123456"); var mapUser = new Dictionary <string, ApplicationUser>(); // role + user List <SeedUserRole> userList = new List <SeedUserRole>(); // admin var admin01 = new ApplicationUser() { Id = "1", UserName = "******", PasswordHash = password, Email = "*****@*****.**", EmailConfirmed = true, PhoneNumber = "+84941819959", PhoneNumberConfirmed = true, LockoutEnabled = true, }; userList.Add(new SeedUserRole() { User = admin01, RoleId = "1" }); var admin02 = new ApplicationUser() { Id = "2", UserName = "******", PasswordHash = password, Email = "*****@*****.**", EmailConfirmed = true, PhoneNumber = "+84979650208", PhoneNumberConfirmed = true, LockoutEnabled = true, }; userList.Add(new SeedUserRole() { User = admin02, RoleId = "2" }); var admin03 = new ApplicationUser() { Id = "3", UserName = "******", PasswordHash = password, Email = "*****@*****.**", EmailConfirmed = true, PhoneNumber = "+84376316448", PhoneNumberConfirmed = true, LockoutEnabled = true, }; userList.Add(new SeedUserRole() { User = admin03, RoleId = "2" }); var admin04 = new ApplicationUser() { Id = "4", UserName = "******", PasswordHash = password, Email = "*****@*****.**", EmailConfirmed = true, PhoneNumber = "+84347561935", PhoneNumberConfirmed = true, LockoutEnabled = true, }; userList.Add(new SeedUserRole() { User = admin04, RoleId = "2" }); //// user //var user05 = new ApplicationUser() //{ // Id = "5", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434657896", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user05, RoleId = "3" }); //var user06 = new ApplicationUser() //{ // Id = "6", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434657652", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user06, RoleId = "3" }); //var user07 = new ApplicationUser() //{ // Id = "7", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434362214", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user07, RoleId = "3" }); //var user08 = new ApplicationUser() //{ // Id = "8", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434236956", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user08, RoleId = "3" }); //var user09 = new ApplicationUser() //{ // Id = "9", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434698569", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user09, RoleId = "3" }); //var user10 = new ApplicationUser() //{ // Id = "10", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+8434698236", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user10, RoleId = "3" }); //var user11 = new ApplicationUser() //{ // Id = "11", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+84347561955", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user11, RoleId = "3" }); //var user12 = new ApplicationUser() //{ // Id = "12", // UserName = "******", // PasswordHash = password, // Email = "*****@*****.**", // EmailConfirmed = true, // PhoneNumber = "+84347561875", // PhoneNumberConfirmed = true, // LockoutEnabled = true, //}; //userList.Add(new SeedUserRole() { User = user12, RoleId = "3" }); // seed user + userRole foreach (var seedUserRole in userList) { var roleIdTemp = seedUserRole.RoleId; var userTemp = seedUserRole.User; var userRoleTemp = new IdentityUserRole(); userRoleTemp.RoleId = roleIdTemp; userRoleTemp.UserId = userTemp.Id; userTemp.Roles.Add(userRoleTemp); context.Users.AddOrUpdate(x => x.Id, userTemp); } // Category context.Categories.AddOrUpdate(x => x.Id, new Category() { Id = 1, Name = "T-Shirt", Status = ECategoryStatus.Active, CreatedAt = DateTime.Parse("2019-04-24") }, new Category() { Id = 2, Name = "Shirt", Status = ECategoryStatus.Active, CreatedAt = DateTime.Parse("2019-04-24") }, new Category() { Id = 3, Name = "Short", Status = ECategoryStatus.Active, CreatedAt = DateTime.Parse("2019-04-24") }, new Category() { Id = 4, Name = "Jeans", Status = ECategoryStatus.Active, CreatedAt = DateTime.Parse("2019-04-24") } ); //Product context.Products.AddOrUpdate(x => x.Id, //T-shirt 1 new Product() { Id = 1, Name = "SUPIMA© COTTON CREW NECK SHORT-SLEEVE T-SHIRT", Price = 14.9, Discount = 9.9, Description = "100% Supima® cotton for a high-quality feel. A basic item that goes with any look.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/sub/goods_422990_sub7.jpg", CategoryId = 1, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-04-24") }, //T-shirt 2 new Product() { Id = 2, Name = "DRY V-NECK SHORT-SLEEVE COLOR T-SHIRT", Price = 7.9, Description = "Simple and versatile. Stays dry, giving it a comfortable and dry feeling against the skin.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/sub/goods_427916_sub7.jpg", CategoryId = 1, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-05-24") }, //Shirt 3 new Product() { Id = 3, Name = "EXTRA FINE COTTON SHORT-SLEEVE SHIRT", Price = 29.9, Discount = 19.9, Description = "Made from fine cotton for a soft feel. The surface is soft for a more comfortable feel.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/sub/goods_427315_sub7.jpg", CategoryId = 2, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2019-10-24") }, //Shirt 4 new Product() { Id = 4, Name = "EXTRA FINE COTTON BROADCLOTH SHORT-SLEEVE SHIRT", Price = 29.9, Description = "Made with fine cotton to reduce wrinkles after washing.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/sub/goods_426933_sub7.jpg", CategoryId = 2, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-05-10") }, //Short 5 new Product() { Id = 5, Name = "NYLON ACTIVE SHORTS", Price = 29.9, Description = "Both materials and details have a sporty finish. A different take on a stylish piece.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/sub/goods_425150_sub8.jpg", CategoryId = 3, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-03-24") }, //Short 6 new Product() { Id = 6, Name = "ERSEY EASY SHORTS", Price = 19.9, Description = "These relaxed pants are soft and comfortable. Short and easy to wear.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/sub/goods_424152_sub7.jpg", CategoryId = 3, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-04-15") }, //Jeans 7 new Product() { Id = 7, Name = "EZY ULTRA STRETCH COLOR JEANS", Price = 39.9, Discount = 29.9, Description = "Ultra stretch fabric makes it incredibly comfortable. Refined design and texture.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/sub/goods_422368_sub7.jpg", CategoryId = 4, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2020-01-24") }, //Jeans 8 new Product() { Id = 8, Name = "ULTRA STRETCH SKINNY FIT JEANS", Price = 49.9, Description = "The slimmest skinny fit of all UNIQLO jeans. It's surprisingly flexible and still comfortable.", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/sub/goods_425297_sub7.jpg", CategoryId = 4, Status = EProductStatus.Active, CreatedAt = DateTime.Parse("2019-12-24") } ); //Product Details context.ProductDetails.AddOrUpdate(x => x.Id, //T-shirt 1 new ProductDetail() { Id = 1, ProductId = 1, Color = "Navy", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_69_422990.jpg", Quantity = 18, Status = EProductStatus.Active, }, new ProductDetail() { Id = 2, ProductId = 1, Color = "Navy", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_69_422990.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 3, ProductId = 1, Color = "Navy", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_69_422990.jpg", Quantity = 45, Status = EProductStatus.Deleted, }, new ProductDetail() { Id = 4, ProductId = 1, Color = "Beige", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_32_422990.jpg", Quantity = 31, Status = EProductStatus.Active, }, new ProductDetail() { Id = 5, ProductId = 1, Color = "Beige", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_32_422990.jpg", Quantity = 21, Status = EProductStatus.Deactive, }, new ProductDetail() { Id = 6, ProductId = 1, Color = "Beige", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422990/item/goods_32_422990.jpg?", Quantity = 11, Status = EProductStatus.Active, }, //T-shirt 2 new ProductDetail() { Id = 7, ProductId = 2, Color = "Gray", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_03_427916.jpg", Quantity = 22, Status = EProductStatus.Active, }, new ProductDetail() { Id = 8, ProductId = 2, Color = "Gray", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_03_427916.jpg", Quantity = 32, Status = EProductStatus.Active, }, new ProductDetail() { Id = 9, ProductId = 2, Color = "Gray", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_03_427916.jpg", Quantity = 22, Status = EProductStatus.Active, }, new ProductDetail() { Id = 10, ProductId = 2, Color = "Dark Gray", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_08_427916.jpg", Quantity = 12, Status = EProductStatus.Active, }, new ProductDetail() { Id = 11, ProductId = 2, Color = "Dark Gray", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_08_427916.jpg", Quantity = 34, Status = EProductStatus.Active, }, new ProductDetail() { Id = 12, ProductId = 2, Color = "Dark Gray", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427916/item/goods_08_427916.jpg", Quantity = 10, Status = EProductStatus.Active, }, //Shirt 3 new ProductDetail() { Id = 13, ProductId = 3, Color = "Yellow", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_48_427315.jpg", Quantity = 14, Status = EProductStatus.Deactive, }, new ProductDetail() { Id = 14, ProductId = 3, Color = "Yellow", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_48_427315.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 15, ProductId = 3, Color = "Yellow", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_48_427315.jpg", Quantity = 42, Status = EProductStatus.Active, }, new ProductDetail() { Id = 16, ProductId = 3, Color = "White", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_00_427315.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 17, ProductId = 3, Color = "White", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_00_427315.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 18, ProductId = 3, Color = "White", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/427315/item/goods_00_427315.jpg", Quantity = 35, Status = EProductStatus.Active, }, //Shirt 4 new ProductDetail() { Id = 19, ProductId = 4, Color = "Blue", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/sub/goods_426933_sub4.jpg", Quantity = 25, Status = EProductStatus.Active, }, new ProductDetail() { Id = 20, ProductId = 4, Color = "Blue", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/sub/goods_426933_sub4.jpg", Quantity = 15, Status = EProductStatus.Active, }, new ProductDetail() { Id = 21, ProductId = 4, Color = "Blue", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/sub/goods_426933_sub4.jpg", Quantity = 20, Status = EProductStatus.Active, }, new ProductDetail() { Id = 22, ProductId = 4, Color = "Yellow", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/item/goods_45_426933.jpg", Quantity = 30, Status = EProductStatus.Active, }, new ProductDetail() { Id = 23, ProductId = 4, Color = "Yellow", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/item/goods_45_426933.jpg", Quantity = 40, Status = EProductStatus.Active, }, new ProductDetail() { Id = 24, ProductId = 4, Color = "Yellow", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/426933/item/goods_45_426933.jpg", Quantity = 8, Status = EProductStatus.Deleted, }, //Short 5 new ProductDetail() { Id = 25, ProductId = 5, Color = "Gray", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/sub/goods_425150_sub3.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 26, ProductId = 5, Color = "Gray", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/sub/goods_425150_sub3.jpg", Quantity = 15, Status = EProductStatus.Active, }, new ProductDetail() { Id = 27, ProductId = 5, Color = "Gray", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/sub/goods_425150_sub3.jpg", Quantity = 15, Status = EProductStatus.Active, }, new ProductDetail() { Id = 28, ProductId = 5, Color = "Green", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/item/goods_55_425150.jpg", Quantity = 25, Status = EProductStatus.Active, }, new ProductDetail() { Id = 29, ProductId = 5, Color = "Green", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/item/goods_55_425150.jpg", Quantity = 30, Status = EProductStatus.Active, }, new ProductDetail() { Id = 30, ProductId = 5, Color = "Green", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425150/item/goods_55_425150.jpg", Quantity = 8, Status = EProductStatus.Active, }, //Short 6 new ProductDetail() { Id = 31, ProductId = 6, Color = "Green", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_69_424152.jpg", Quantity = 2, Status = EProductStatus.Active, }, new ProductDetail() { Id = 32, ProductId = 6, Color = "Green", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_69_424152.jpg", Quantity = 30, Status = EProductStatus.Active, }, new ProductDetail() { Id = 33, ProductId = 6, Color = "Green", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_69_424152.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 34, ProductId = 6, Color = "Red", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_13_424152.jpg", Quantity = 19, Status = EProductStatus.Active, }, new ProductDetail() { Id = 35, ProductId = 6, Color = "Red", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_13_424152.jpg", Quantity = 22, Status = EProductStatus.Active, }, new ProductDetail() { Id = 36, ProductId = 6, Color = "Red", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/424152/item/goods_13_424152.jpg", Quantity = 15, Status = EProductStatus.Active, }, //Jeans 7 new ProductDetail() { Id = 37, ProductId = 7, Color = "Blue", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/sub/goods_422368_sub3.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 38, ProductId = 7, Color = "Blue", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/sub/goods_422368_sub3.jpg", Quantity = 10, Status = EProductStatus.Active, }, new ProductDetail() { Id = 39, ProductId = 7, Color = "Blue", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/sub/goods_422368_sub3.jpg", Quantity = 10, Status = EProductStatus.Deleted, }, new ProductDetail() { Id = 40, ProductId = 7, Color = "Olive", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/item/goods_56_422368.jpg", Quantity = 10, Status = EProductStatus.Deactive, }, new ProductDetail() { Id = 41, ProductId = 7, Color = "Olive", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/item/goods_56_422368.jpg", Quantity = 18, Status = EProductStatus.Active, }, new ProductDetail() { Id = 42, ProductId = 7, Color = "Olive", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/422368/item/goods_56_422368.jpg", Quantity = 15, Status = EProductStatus.Active, }, //Jeans 8 new ProductDetail() { Id = 43, ProductId = 8, Color = "Blue", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/sub/goods_425297_sub3.jpg", Quantity = 0, Status = EProductStatus.Deactive, }, new ProductDetail() { Id = 44, ProductId = 8, Color = "Blue", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/sub/goods_425297_sub3.jpg", Quantity = 5, Status = EProductStatus.Active, }, new ProductDetail() { Id = 45, ProductId = 8, Color = "Blue", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/sub/goods_425297_sub3.jpg", Quantity = 20, Status = EProductStatus.Active, }, new ProductDetail() { Id = 46, ProductId = 8, Color = "Dark Gray", Size = "S", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/item/goods_08_425297.jpg", Quantity = 0, Status = EProductStatus.Deleted, }, new ProductDetail() { Id = 47, ProductId = 8, Color = "Dark Gray", Size = "M", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/item/goods_08_425297.jpg", Quantity = 8, Status = EProductStatus.Deactive, }, new ProductDetail() { Id = 48, ProductId = 8, Color = "Dark Gray", Size = "L", Thumbnails = "https://image.uniqlo.com/UQ/ST3/WesternCommon/imagesgoods/425297/item/goods_08_425297.jpg", Quantity = 10, Status = EProductStatus.Active, } ); //Discount context.Discounts.AddOrUpdate(x => x.Id, new Discount() { Code = "ALISALE001", Value = 0.2, ExprirationDate = DateTime.Parse("2021-10-24"), MinTotal = 100, UseTime = 1, Status = EDiscountStatus.Active, CreatedAt = DateTime.Parse("2020-04-24") }, new Discount() { Code = "ALISALE002", Value = 0.1, ExprirationDate = DateTime.Parse("2021-10-24"), MinTotal = 50, UseTime = 10, Status = EDiscountStatus.Active, CreatedAt = DateTime.Parse("2020-04-24") } ); //Order01 var order01 = new Order() { CustomerName = "Matt Addie", CustomerPhone = "(423) 610-3161", CustomerEmail = "*****@*****.**", CustomerAddress = "777 Brockton Avenue, Abington MA 2351", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 25.7, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-01-24") }; var orderDetail01 = new OrderDetail() { OrderId = 1, ProductDetailId = 1, UnitPrice = 14.9, Discount = 9.9, Quantity = 1, }; var orderDetail02 = new OrderDetail() { OrderId = 1, ProductDetailId = 7, UnitPrice = 7.9, //Discount = 9.9, Quantity = 2, }; order01.AddOrderDetail(orderDetail01); order01.AddOrderDetail(orderDetail02); context.Orders.AddOrUpdate(order01); //Order02 var order02 = new Order() { CustomerName = "Allen Quimby", CustomerPhone = "(739) 261-3110", CustomerEmail = "*****@*****.**", CustomerAddress = "30 Memorial Drive, Avon MA 2322", PaymentMethod = EPaymentMethod.Paypal, TotalPrice = 209.3, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-01-15") }; var orderDetail03 = new OrderDetail() { OrderId = 2, ProductDetailId = 30, UnitPrice = 29.9, //Discount = 9.9, Quantity = 3, }; var orderDetail04 = new OrderDetail() { OrderId = 2, ProductDetailId = 25, UnitPrice = 29.9, //Discount = 9.9, Quantity = 4, }; order02.AddOrderDetail(orderDetail03); order02.AddOrderDetail(orderDetail04); context.Orders.AddOrUpdate(order02); //Order03 var order03 = new Order() { CustomerName = "Weldon Ries", CustomerPhone = "(314) 345-9898", CustomerEmail = "*****@*****.**", CustomerAddress = "250 Hartford Avenue, Bellingham MA 2019", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 139.6, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-02-24") }; var orderDetail05 = new OrderDetail() { OrderId = 3, ProductDetailId = 42, UnitPrice = 39.9, Discount = 29.9, Quantity = 3, }; var orderDetail06 = new OrderDetail() { OrderId = 3, ProductDetailId = 45, UnitPrice = 49.9, //Discount = 9.9, Quantity = 1, }; order03.AddOrderDetail(orderDetail05); order03.AddOrderDetail(orderDetail06); context.Orders.AddOrUpdate(order03); //Order04 var order04 = new Order() { CustomerName = "Cary Mcmurtrie", CustomerPhone = "(797) 740-3175", CustomerEmail = "*****@*****.**", CustomerAddress = "66-4 Parkhurst Rd, Chelmsford MA 1824", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 45.7, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-02-02") }; var orderDetail07 = new OrderDetail() { OrderId = 4, ProductDetailId = 12, UnitPrice = 7.9, //Discount = 29.9, Quantity = 2, }; var orderDetail08 = new OrderDetail() { OrderId = 4, ProductDetailId = 20, UnitPrice = 29.9, //Discount = 9.9, Quantity = 1, }; order04.AddOrderDetail(orderDetail07); order04.AddOrderDetail(orderDetail08); context.Orders.AddOrUpdate(order04); //Order05 var order05 = new Order() { CustomerName = "Wade Coy", CustomerPhone = "(696) 658-5886", CustomerEmail = "*****@*****.**", CustomerAddress = "591 Memorial Dr, Chicopee MA 1020", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 79.6, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-02-19") }; var orderDetail09 = new OrderDetail() { OrderId = 5, ProductDetailId = 35, UnitPrice = 19.9, //Discount = 29.9, Quantity = 2, }; var orderDetail10 = new OrderDetail() { OrderId = 5, ProductDetailId = 15, UnitPrice = 29.9, Discount = 19.9, Quantity = 2, }; order05.AddOrderDetail(orderDetail09); order05.AddOrderDetail(orderDetail10); context.Orders.AddOrUpdate(order05); //Order06 var order06 = new Order() { CustomerName = "Winfred Kitamura", CustomerPhone = "(544) 926-3679", CustomerEmail = "*****@*****.**", CustomerAddress = "55 Brooksby Village Way, Danvers MA 1923", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 169.5, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-03-24") }; var orderDetail11 = new OrderDetail() { OrderId = 6, ProductDetailId = 24, UnitPrice = 29.9, //Discount = 29.9, Quantity = 4, }; var orderDetail12 = new OrderDetail() { OrderId = 6, ProductDetailId = 43, UnitPrice = 49.9, //Discount = 19.9, Quantity = 1, }; order06.AddOrderDetail(orderDetail11); order06.AddOrderDetail(orderDetail12); context.Orders.AddOrUpdate(order06); //Order07 var order07 = new Order() { CustomerName = "Winfred Kitamura", CustomerPhone = "(544) 926-3679", CustomerEmail = "*****@*****.**", CustomerAddress = "55 Brooksby Village Way, Danvers MA 1923", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 169.5, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-03-16") }; var orderDetail13 = new OrderDetail() { OrderId = 7, ProductDetailId = 24, UnitPrice = 29.9, //Discount = 29.9, Quantity = 4, }; var orderDetail14 = new OrderDetail() { OrderId = 7, ProductDetailId = 43, UnitPrice = 49.9, //Discount = 19.9, Quantity = 1, }; order07.AddOrderDetail(orderDetail13); order07.AddOrderDetail(orderDetail14); context.Orders.AddOrUpdate(order07); //Order08 var order08 = new Order() { CustomerName = "Winfred Kitamura", CustomerPhone = "(544) 926-3679", CustomerEmail = "*****@*****.**", CustomerAddress = "55 Brooksby Village Way, Danvers MA 1923", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 169.5, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-04-24") }; var orderDetail15 = new OrderDetail() { OrderId = 8, ProductDetailId = 24, UnitPrice = 29.9, //Discount = 29.9, Quantity = 4, }; var orderDetail16 = new OrderDetail() { OrderId = 8, ProductDetailId = 43, UnitPrice = 49.9, //Discount = 19.9, Quantity = 1, }; order08.AddOrderDetail(orderDetail15); order08.AddOrderDetail(orderDetail16); context.Orders.AddOrUpdate(order08); //Order09 var order09 = new Order() { CustomerName = "Winfred Kitamura", CustomerPhone = "(544) 926-3679", CustomerEmail = "*****@*****.**", CustomerAddress = "55 Brooksby Village Way, Danvers MA 1923", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 169.5, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-04-04") }; var orderDetail17 = new OrderDetail() { OrderId = 9, ProductDetailId = 24, UnitPrice = 29.9, //Discount = 29.9, Quantity = 4, }; var orderDetail18 = new OrderDetail() { OrderId = 9, ProductDetailId = 43, UnitPrice = 49.9, //Discount = 19.9, Quantity = 1, }; order08.AddOrderDetail(orderDetail15); order08.AddOrderDetail(orderDetail16); context.Orders.AddOrUpdate(order08); //Order10 var order10 = new Order() { CustomerName = "Winfred Kitamura", CustomerPhone = "(544) 926-3679", CustomerEmail = "*****@*****.**", CustomerAddress = "55 Brooksby Village Way, Danvers MA 1923", PaymentMethod = EPaymentMethod.Cash, TotalPrice = 169.5, Status = EOrderStatus.Delivered, CreatedAt = DateTime.Parse("2020-05-19") }; var orderDetail19 = new OrderDetail() { OrderId = 10, ProductDetailId = 24, UnitPrice = 29.9, //Discount = 29.9, Quantity = 4, }; var orderDetail20 = new OrderDetail() { OrderId = 10, ProductDetailId = 43, UnitPrice = 49.9, //Discount = 19.9, Quantity = 1, }; order10.AddOrderDetail(orderDetail19); order10.AddOrderDetail(orderDetail20); context.Orders.AddOrUpdate(order10); }
public ActionResult Update([Bind(Prefix = "item1")] Order order, [Bind(Prefix = "item2")] OrderDetail od) { orep.Update(order); odrep.Update(od); return(RedirectToAction("List")); }
public ActionResult DatHang(string shipName, string shipMobile, string shipAddress, string shipEmail) { if (Session["cart"] == null) { return(RedirectToAction("Index", "Home")); } //Thêm chi tiết vào giỏ hàng Customer cus = new Customer(); Customer test = model.Customers.SingleOrDefault(x => x.shipName == shipName && x.shipMobile == shipMobile && x.shipAddress == shipAddress && x.shipEmail == shipEmail); if (test != null) { cus.makhachhang = test.makhachhang; cus.shipName = test.shipName; cus.shipMobile = test.shipMobile; cus.shipAddress = test.shipAddress; cus.shipEmail = test.shipEmail; } else { cus.shipName = shipName; cus.shipMobile = shipMobile; cus.shipAddress = shipAddress; cus.shipEmail = shipEmail; model.Customers.Add(cus); model.SaveChanges(); } ShoppingCart Cart = (ShoppingCart)Session["cart"]; Order order = new Order(); order.ngaydathang = DateTime.Now; order.ngaygiaohang = DateTime.Now; order.status = "Đang giao hang"; order.makhachhang = cus.makhachhang; model.Orders.Add(order); model.SaveChanges(); CategoryDao categoryDao = new CategoryDao(); List <ItemCart> listItem = new List <ItemCart>(); IndexData data = new IndexData(); data.listCategory = categoryDao.GetCategory(); if (Cart != null) { data.listItemCart = Cart.listItem; foreach (var item in data.listItemCart) { OrderDetail detail = new OrderDetail(); detail.madathang = order.ma; detail.masanpham = item.Product.ma; detail.soluong = item.soluong; detail.dongia = item.Product.dongia; Product sp = model.Products.Find(detail.masanpham); sp.soluong = sp.soluong - item.soluong; SubCategory subcategory = model.SubCategories.Find(sp.producttype); subcategory.soluong = subcategory.soluong - item.soluong; Category category = model.Categories.Find(subcategory.danhmucma); category.soluong = category.soluong - item.soluong; model.OrderDetails.Add(detail); model.SaveChanges(); } ViewData["DonHang"] = order; } return(View(data)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Verify user has completed the checkout process. if ((string)Session["userCheckoutCompleted"] != "true") { Session["userCheckoutCompleted"] = string.Empty; Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout."); } if (Session["payment_method"].ToString() == "PayPal") { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string finalPaymentAmount = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); PayerID = Session["payerId"].ToString(); finalPaymentAmount = Session["payment_amt"].ToString(); bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg); if (ret) { // Retrieve PayPal confirmation value. string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString(); TransactionId.Text = PaymentConfirmation; ProductContext _db = new ProductContext(); // Get the current order id. int currentOrderId = -1; if (Session["currentOrderId"].ToString() != string.Empty) { currentOrderId = Convert.ToInt32(Session["currentOrderID"]); } Order myCurrentOrder; if (currentOrderId >= 0) { // Get the order based on order id. myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId); // Update the order to reflect payment has been completed. myCurrentOrder.PaymentTransactionId = PaymentConfirmation; // Save to DB. _db.SaveChanges(); } // Clear order id. Session["currentOrderId"] = string.Empty; } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } else if (Session["payment_method"].ToString() == "Braintree") { var myOrder = new Models.Order(); var myAddress = new Models.Address(); var manager = HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>(); var user = manager.FindByName(HttpContext.Current.User.Identity.Name); myOrder.OrderDate = DateTime.Now; myOrder.Email = user.Email; myAddress.UserName = user.Email; myAddress.AddressLine1 = Session["streetNumberValue"].ToString() + " " + Session["routeValue"].ToString(); myAddress.City = Session["cityValue"].ToString(); myAddress.State = Session["stateValue"].ToString(); myAddress.PostalCode = Session["postalCodeValue"].ToString(); myAddress.Country = Session["countryValue"].ToString(); myOrder.Email = user.Email; myOrder.PaymentTransactionId = "Stripe" + Session["token"].ToString(); myOrder.Total = Convert.ToDecimal(HttpContext.Current.Session["payment_amt"].ToString()); ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.Addresses.Add(myAddress); _db.SaveChanges(); using (fashionUtilityApplication.Logic.ShoppingCartActions usersShoppingCart = new fashionUtilityApplication.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = HttpContext.Current.User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.ImagePath = myOrderList[i].ImagePath; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. HttpContext.Current.Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <fashionUtilityApplication.Models.Order> orderList = new List <fashionUtilityApplication.Models.Order>(); orderList.Add(myOrder); } } else { Response.Redirect("CheckoutError.aspx?"); } // Clear shopping cart. using (fashionUtilityApplication.Logic.ShoppingCartActions usersShoppingCart = new fashionUtilityApplication.Logic.ShoppingCartActions()) { usersShoppingCart.EmptyCart(); } } }
public JsonResult purchase(string fullName, string email, int phone, string county, string address, string description) { //khach hang khong dang nhap Customer customer = new Customer(); if (Session["id_Customer"] == null) { customer.email = email; customer.password = EncryptPassword.EncryptForPassword(phone.ToString()); customer.fullname = fullName; customer.phone = phone; customer.address = address; customer.avatar = "Assets/Client/resources/image/" + "customerDefault.jpg"; customer.idCounty = Int32.Parse(county); customer.activated = true; customer.status = true; customer.createdDate = DateTime.Now; customer.modifyDate = DateTime.Now; customer.modifyBy = fullName; customer.dayOfBirth = DateTime.Now; customer.roleId = 3; db.Customers.Add(customer); db.SaveChanges(); SendEmail.SendMail("Gửi từ Laundry Store, Xác nhận người dùng ! ", customer.email, " Bạn vừa đăng kí thành công tài khoản tại Laundry Store !" + " Với tên đăng nhập : " + customer.email + " Bạn có thể sử dụng email trên để đăng nhập vào cửa hàng của chúng tôi với mật khẩu là số điện thoại của bạn : " + customer.phone + " " + " Vui lòng truy cập vào đường dẫn dưới đây để cập nhật thông tin tài khoản " + "https://localhost:44335/Account/infoProfile/" + customer.id); } else { var customerId = int.Parse(Session["id_Customer"].ToString()); customer = db.Customers.Find(customerId); if (customer != null) { customer.email = email; customer.fullname = fullName; customer.phone = phone; customer.address = address; customer.idCounty = Int32.Parse(county); customer.modifyDate = DateTime.Now; customer.modifyBy = Session["username_Customer"].ToString(); db.SaveChanges(); } } //them don hang vao trong order Order order = new Order(); order.customerId = customer.id; order.orderDate = DateTime.Now; order.address = address; order.paymentMethodId = 1; order.paymentStatus = "doing"; order.amount = totalQuantity(); order.description = description; order.statusId = 2; order.createdBy = customer.fullname; order.shippingId = 1; order.totalDebt = 0; order.status = true; double?total = totalMoney(); order.totalOrder = Convert.ToInt64(total); db.Orders.Add(order); db.SaveChanges(); //insert table barcodes Barcode barcode = new Barcode(); barcode.orderId = order.id; barcode.codeName = RandomBarCodes.RandomBarCode(); barcode.createdDate = DateTime.Now; barcode.createdBy = fullName; db.Barcodes.Add(barcode); db.SaveChanges(); //them don hang vao chi tiet don hang List <CartItem> listCart = getCart(); foreach (CartItem item in listCart) { OrderDetail orderDetail = new OrderDetail(); orderDetail.orderId = order.id; orderDetail.productId = Convert.ToInt32(item.productId); orderDetail.discount = item.discount; orderDetail.price = item.price; orderDetail.type = item.type; orderDetail.status = true; orderDetail.totalPrice = Convert.ToInt64(item.total); db.OrderDetails.Add(orderDetail); db.SaveChanges(); } Session["cart"] = null; if (Session["id_Customer"] == null) { return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(2, JsonRequestBehavior.AllowGet)); }
public async Task <bool> createOrder(CheckOutModels model) { var dateTime = DateTime.UtcNow; var _orderNewStatus = ""; Order _order = new Order() { Id = Guid.NewGuid().ToString(), AspNetUserId = model.UserId, DateCreated = dateTime, }; //set order status and orderdetail status if paid if (model.PaymentStatus == "paid") { _orderNewStatus = "shipping"; } OrderDetailShippingAddress _shipping = new OrderDetailShippingAddress() { Id = Guid.NewGuid().ToString(), Line1 = model.ShippingAddress.Line1, Line2 = model.ShippingAddress.Line2, State = model.ShippingAddress.State, City = model.ShippingAddress.City, OdersId = _order.Id }; data.Orders.Add(_order); data.OrderDetailShippingAddresses.Add(_shipping); foreach (var o in model.Cart) { OrderDetail _orderDetail = new OrderDetail() { Id = Guid.NewGuid().ToString(), DateAdded = dateTime, ProductsId = o.Id, OrdersId = _order.Id, ProductAmount = o.Amount, Quantity = o.Quantity, OrderDetailsStatus = _orderNewStatus }; data.OrderDetails.Add(_orderDetail); } //payment entry var _payment = new Payment() { Id = Guid.NewGuid().ToString(), AspNetUserId = model.UserId, PaymentDate = dateTime, OrdersId = _order.Id }; var _paymentDetail = new PaymentDetail() { Id = Guid.NewGuid().ToString(), PaymentId = _payment.Id, PaymentRef = model.PaymentRef, PayerName = model.BillingAddress.name, PaymentAmount = model.TotalAmount, PaymentMethodId = model.PaymentMethodId }; data.Payments.Add(_payment); data.PaymentDetails.Add(_paymentDetail); //remove selected item from cart var _forDeleteItem = await data.Carts.Where(i => i.AspNetUserId == model.UserId && i.IsSelected == true).ToListAsync(); data.Carts.RemoveRange(_forDeleteItem); try { await data.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
public void Order(List <CartViewModel> ses, OrderViewModel ordermodel, string name) { List <CartViewModel> model; model = ses; using (PetsPlanetDBContext db = new PetsPlanetDBContext()) { using (var transaction = db.Database.BeginTransaction()) { try { var date = DateTime.Now; var userid = db.User_Info.Where(x => x.US_Name == name).FirstOrDefault <User_Info>(); #region *** Order Details Table Entry *** OrderDetail od = new OrderDetail(); od.US_Id = userid.US_Id; od.DeliveryAddress = ordermodel.DeliveryAddress; od.Phone1 = ordermodel.Phone1; od.Phone2 = ordermodel.Phone2; od.TotalPrice = ordermodel.TotalPrice; od.Totalitem = ordermodel.Totalitem; od.US_Name = ordermodel.US_Name; od.OrderStatus = "In process"; od.OrderDate = date.Date; db.OrderDetails.Add(od); db.SaveChanges(); #endregion *** Order Details Table Entry *** #region *** Order Items Table Entry *** List <OrderItem> oiList = new List <OrderItem>(); foreach (var items in model) { var productInventoryID = db.Product_Inventory.Where(x => x.PC3_Id == items.PC3_Id).FirstOrDefault <Product_Inventory>(); var VendorProductID = db.Vendor_Products.Where(x => x.PI_Id == productInventoryID.PI_Id).FirstOrDefault <Vendor_Product>(); var VendorProductQuantityID = db.Vendor_Product_Qties.Where(x => x.VP_Id == VendorProductID.VP_Id).FirstOrDefault <Vendor_Product_Qty>(); var VendorProductCostID = db.Vendor_Product_Cost.Where(x => x.VPQ_Id == VendorProductQuantityID.VPQ_Id).FirstOrDefault <Vendor_Product_Cost>(); OrderItem oi = new OrderItem { OD_Id = od.OD_Id, VPC_Id = VendorProductCostID.VPC_Id, UnitPrice = VendorProductCostID.Vendor_Price, QuantityOrder = items.OD_ProductQty, TotalItemPrice = (VendorProductCostID.Vendor_Price * items.OD_ProductQty) }; oiList.Add(oi); } db.OrderItems.AddRange(oiList); db.SaveChanges(); #endregion *** Order Items Table Entry *** transaction.Commit(); model.Clear(); } catch { transaction.Rollback(); } } } }
public async Task <IActionResult> PostOrder([FromBody] OrdDetails orderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var shoppingCart = _context.Cart.Where(c => c.UserId == orderdetail.userid); Random generator = new Random(); String r = generator.Next(0, 9999999).ToString("D6"); int orderno = Int32.Parse(r); string date = DateTime.Now.ToString("D"); var orders = new Order { OrderId = orderno, date = date, Total = orderdetail.total }; _context.Database.OpenConnection(); try { _context.Orders.Add(orders); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Orders ON"); await _context.SaveChangesAsync(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Orders OFF"); foreach (Cart item in shoppingCart) { var orderDetailJohn = new OrderDetail { OrderId = orderno, productId = item.ProductId, userid = item.UserId, quantity = item.Quantity, }; _context.OrderDetails.Add(orderDetailJohn); } _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Orders ON"); await _context.SaveChangesAsync(); _context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT dbo.Orders OFF"); } finally { _context.Database.CloseConnection(); } _context.Cart.Remove(_context.Cart.First(t => t.UserId == orderdetail.userid)); await _context.SaveChangesAsync(); // _context.Cart.Remove(_context.Cart.Find(orderdetail.userid)); return(Ok()); }
public ActionResult Payment(string ShipName, string Mobile, string Address, string Email) { var order = new Order(); order.Id = Guid.NewGuid(); order.CreateDate = DateTime.Now; order.ShipName = ShipName; order.ShipMobile = Mobile; order.ShipAddress = Address; order.ShipEmail = Email; order.Status = true; if (User.Identity.IsAuthenticated) { order.CreateBy = User.Identity.Name; } var id = _orderService.Insert(order); var list = new List <CartItem>(); int i = -1; while (1 != 2) { i++; HttpCookie cooki = HttpContext.Request.Cookies[i.ToString()];// lấy cookie if (cooki == null) { break; } string valueCookie = Server.UrlDecode(cooki.Value); //Decode dịch ngược mã các ký tự đặc biệt tham khảo var cart2 = JsonConvert.DeserializeObject <List <CartItem> >(valueCookie); // convert json to list object var list2 = (List <CartItem>)cart2; list.AddRange(list2); } foreach (var item in list) { var orderDetail = new OrderDetail(); orderDetail.Id = Guid.NewGuid(); orderDetail.ProductID = item.Product.Id; orderDetail.OrderID = id; orderDetail.Price = (item.Product.Price * item.Quatity); orderDetail.Quantity = item.Quatity; var detail = _orderDetailService.Insert(orderDetail); } //Xóa i = -1; while (1 != 2) { i++; HttpCookie cooki = HttpContext.Request.Cookies[i.ToString()];// lấy cookie if (cooki == null) { break; } cooki.Expires = DateTime.Now.AddDays(-1); HttpContext.Response.Cookies.Add(cooki); } return(Redirect("/hoan-thanh")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVPAPICaller payPalCaller = new NVPAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.Username = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } // Get DB context. ProductContext _db = new ProductContext(); // Add order to DB. _db.Orders.Add(myOrder); _db.SaveChanges(); // Get the shopping cart items and process them. using (E_shop_books.Logic.ShoppingCartActions usersShoppingCart = new E_shop_books.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); // Add OrderDetail information to the DB for each product purchased. for (int i = 0; i < myOrderList.Count; i++) { // Create a new OrderDetail object. var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.Username = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; // Add OrderDetail to DB. _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } // Set OrderId. Session["currentOrderId"] = myOrder.OrderId; // Display Order information. List <Order> orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); // Display OrderDetails. OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
private static void AddOrderTest() { var address = new Address { City = "Warszawa", PostCode = "01466", Street = "Chłodna" }; //var customer = new Customer //{ // FirstName = "Marcin", // LastName = "Sulecki", // DeliveryAddress = address, // Birthday = DateTime.Now //}; ICustomersService customersService = new DbCustomersService(); var customer = customersService.Get(1); var product1 = new Product { Id = 1, Name = "Mysz", Color = "Red" }; var service1 = new Service { Id = 2, Name = "Szkolenie EF" }; var product2 = new Product { Id = 3, Name = "Klawiatura", Color = "Blue" }; var order = new Order { Customer = customer, DateOrder = DateTime.Now, }; order.Details.Add(new OrderDetail { Item = product1, Quantity = 3, UnitPrice = 99 }); order.Details.Add(new OrderDetail { Item = service1, Quantity = 5, UnitPrice = 100 }); var od = new OrderDetail { Item = product2, Quantity = 5, UnitPrice = 200 }; order.Details.Add(od); order.Details.Add(od); IOrdersService ordersService = new DbOrdersService(); ordersService.Add(order); }
public ActionResult Calculate(FormCollection form) { if (Session["AdminID"] != null) { ViewBag.AdminLogined = true; string printTimeStrings = form["printTimeConsuming"]; string printConsumptionStrings = form["printConsumption"]; string orderParamStrings = form["parameter"].ToString(); string modelIdStrings = form["modelId"].ToString(); string orderId = form["orderId"].ToString(); string[] printTimes = printTimeStrings.Split(new char[] { ',' }); string[] printConsumptions = printConsumptionStrings.Split(new char[] { ',' }); string[] orderParams = orderParamStrings.Split(new char[] { ',' }); string[] modelIds = modelIdStrings.Split(new char[] { ',' }); int count = modelIds.Count(); Orders order = db.Orders.Find(orderId); for (int i = 0; i < count; i++) { double printTime = Convert.ToDouble(printTimes[i]); double printConsumption = Convert.ToDouble(printConsumptions[i]); string[] parameters = orderParams[i].Split(new char[] { ';', ':' }); int materialRatio = 1; switch (parameters[1]) { case "PLA塑料": materialRatio = 1; break; case "ABS塑料": materialRatio = 1; break; case "光敏树脂": materialRatio = 1; break; } int materialColorRatio = 1; int postProcessingRatio = 1; switch (parameters[9]) { case "无需打磨": postProcessingRatio = 0; break; case "打磨内表面": postProcessingRatio = 5; break; case "打磨外表面": postProcessingRatio = 5; break; case "打磨内外表面": postProcessingRatio = 5; break; } double singleModelPrice = 2 * ((0.7 * printTime + 0.2 * printConsumption * materialRatio * materialColorRatio) + postProcessingRatio); string modelId = modelIds[i]; string orderParam = orderParams[i]; OrderDetail orderDetail = db.OrderDetail.Where(n => (n.ModelID == modelId) && (n.PrintParameter == orderParam) && (n.OrderID == orderId)).FirstOrDefault(); orderDetail.Price = Convert.ToDecimal(singleModelPrice); orderDetail.Sums = orderDetail.Price * orderDetail.Counts; orderDetail.State = (Int32)OrderState.WaitConfirm; db.Entry(orderDetail).State = EntityState.Modified; db.SaveChanges(); order.Sums += +orderDetail.Sums; } order.State = (Int32)OrderState.WaitConfirm; db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Orders")); } else { return(RedirectToAction("Index")); } //old version //double printTime = Convert.ToDouble(form["printTimeConsuming"]); //double printConsumption = Convert.ToDouble(form["printConsumption"]); //var modelParam = form["parameter"].ToString(); //var modelId = form["modelId"].ToString(); //var orderId = form["orderId"].ToString(); //string[] s1 = modelParam.Split(new char[] { ' ' }); //int materialRatio = 1; //switch (s1[0]) //{ // case "材料:PLA塑料": // materialRatio = 1; // break; // case "材料:ABS塑料": // materialRatio = 1; // break; // case "材料:光敏树脂": // materialRatio = 1; // break; //} //int materialColorRatio = 1; //int postProcessingRatio = 1; //switch (s1[4]) //{ // case "打磨选项:无需打磨": // postProcessingRatio = 0; // break; // case "打磨选项:打磨内表面": // postProcessingRatio = 5; // break; // case "打磨选项:打磨外表面": // postProcessingRatio = 5; // break; // case "打磨选项:打磨内外表面": // postProcessingRatio = 5; // break; //} //double singleModelPrice = 2 * ((0.7 * printTime + 0.2 * printConsumption * materialRatio * materialColorRatio) + postProcessingRatio); //OrderDetail model = db.OrderDetail.Where(n => (n.ModelID == modelId) && (n.PrintParameter == modelParam) && (n.OrderID == orderId)).FirstOrDefault(); //model.Price = Convert.ToDecimal(singleModelPrice); //model.Sums = model.Price * model.Counts; //db.Entry(model).State = EntityState.Modified; //db.SaveChanges(); //Orders order = db.Orders.Find(orderId); //order.Sums = order.Sums + model.Sums; //db.Entry(order).State = EntityState.Modified; //db.SaveChanges(); //var orders = db.OrderDetail.Where(n => n.OrderID == orderId); //return RedirectToAction("OnlineOffer","Admin",new { orderId = orderId }); }
public void Add(OrderDetail orderDetail) { _orderDetailDal.Add(orderDetail); }
private OrderDetail Edit(OracleConnection conn, OracleTransaction transaction, OrderDetail orderDetail) { string query = $"UPDATE {OrderDetail.TableName} " + $"SET " + $"{OrderDetail.ColumnNames.Count} = {orderDetail.Count} " + $"WHERE {OrderDetail.ColumnNames.OrderId} = {orderDetail.OrderId} " + $"AND {OrderDetail.ColumnNames.ProductId} = :{OrderDetail.ColumnNames.ProductId} " + $"AND {OrderDetail.ColumnNames.RecipeId} = :{OrderDetail.ColumnNames.RecipeId}"; OracleCommand editCommand = new OracleCommand(query, conn); editCommand.Transaction = transaction; editCommand.Parameters.Add(new OracleParameter() { Value = orderDetail.ProductId, ParameterName = $":{OrderDetail.ColumnNames.ProductId}", DbType = System.Data.DbType.Int32 }); editCommand.Parameters.Add(new OracleParameter() { Value = orderDetail.RecipeId, ParameterName = $":{OrderDetail.ColumnNames.RecipeId}", DbType = System.Data.DbType.Int32 }); editCommand.ExecuteNonQuery(); OrderDetail result = orderDetail; return(result); }
/// <summary> /// Update method. /// </summary> /// <param name="orderDetail"></param> public void Edit(OrderDetail orderDetail) { var orderDetailDac = new OrderDetailDAC(); orderDetailDac.UpdateById(orderDetail); }
public ActionResult PayNow(PayNow payNow) { try { string transactionId = ""; BraintreeGateway gateway = new BraintreeGateway(Braintree.Environment.SANDBOX, "yfdwsyrvnk3szzvx", "n6n49xttqyjyfqtt", "e3bdf8c24b739625011a335a2b382ab3"); payNow.Amount = Convert.ToDecimal(Session["GrandTotal"]); var request = new TransactionRequest { Amount = payNow.Amount, CreditCard = new TransactionCreditCardRequest { Number = payNow.CardNumber, ExpirationDate = payNow.ExpMonth + "/" + payNow.ExpYear, CVV = payNow.CVV } }; Result<Transaction> result = gateway.Transaction.Sale(request); transactionId = result.Target.Id; var list = Session["AddtoCartItems"] as List<AddtoCart>; string Email = Session["UserName"].ToString(); Guid userId = db.Users.Where(u => u.EmailID == Email).Single().UsersID; // generate Order Order order = new Order(); decimal? TaxAmount = Convert.ToDecimal(Session["TaxAmount"].ToString()); decimal? TotalAmount = Convert.ToDecimal(Session["GrandTotal"].ToString()); order.OrderID = Guid.NewGuid(); order.UsersID = userId; order.OrderDate = DateTime.Now; order.TaxAmount = TaxAmount; order.TotalAmount = TotalAmount; order.CreateDate = DateTime.Now; order.ModifiedDate = DateTime.Now; db.Orders.Add(order); db.SaveChanges(); // generate Order Details foreach (var product in list) { if (product != null) { OrderDetail orderDetail = new OrderDetail(); orderDetail.OrderDetailID = Guid.NewGuid(); orderDetail.OrderID = order.OrderID; orderDetail.ProductID = product.ProductId; orderDetail.Qty = product.Qty; orderDetail.Price = product.Price; orderDetail.Size = product.Size; orderDetail.CreateDate = DateTime.Now; orderDetail.ModifiedDate = DateTime.Now; var product1 = db.Products.Find(product.ProductId); if(product1 != null) { product1.Qty = (product1.Qty - product.Qty); db.Entry(product1).State = EntityState.Modified; db.SaveChanges(); } db.OrderDetails.Add(orderDetail); db.SaveChanges(); // update query ProductStock } } // generate Payment Info PaymentInfo paymentInfo = new PaymentInfo(); paymentInfo.PaymentInfoID = Guid.NewGuid(); paymentInfo.TransationID = transactionId; paymentInfo.OrderID = order.OrderID; paymentInfo.CreateDate = DateTime.Now; paymentInfo.ModifiedDate = DateTime.Now; db.PaymentInfoes.Add(paymentInfo); db.SaveChanges(); } catch (Exception ex) { throw ex; } return RedirectToAction("ShippingAddress"); //return RedirectToAction("Success"); }
public OrderViewData Create(OrderDetail orderDetail) { var orderDetailOrganizationRoleUserCreator = GetOrganizationRoleUser(orderDetail, od => od.DataRecorderMetaData.DataRecorderCreator.Id); var orderDetailOrganizationRoleUserFor = GetOrganizationRoleUser(orderDetail, od => od.ForOrganizationRoleUserId); var description = orderDetail.Description; if (orderDetail.DetailType == OrderItemType.EventPackageItem) { var package = _eventPackageRepository.GetById(orderDetail.OrderItem.ItemId); description = package == null ? "" : package.Package.Name; } else if (orderDetail.DetailType == OrderItemType.EventTestItem) { var eventTest = _eventTestRepository.GetbyId(orderDetail.OrderItem.ItemId); description = eventTest == null ? "" : eventTest.Test.Name; } else if (orderDetail.DetailType == OrderItemType.ProductItem) { description = _electronicProductRepository.GetElectronicProductNameForOrder(orderDetail.OrderItemId); } var customer = _customerRepository.GetCustomerByUserId(orderDetailOrganizationRoleUserFor.FirstValue.UserId); //var creatorRoleName = // ((Roles)orderDetailOrganizationRoleUserCreator.FirstValue.RoleId).ToString(); var orderDetailDateCreated = orderDetail.DataRecorderMetaData != null ? orderDetail.DataRecorderMetaData.DateCreated.ToString("MMM dd yyyy") : null; var eventCustomerId = (orderDetail.DetailType == OrderItemType.EventPackageItem || orderDetail.DetailType == OrderItemType.EventTestItem) && orderDetail.EventCustomerOrderDetail != null ? orderDetail.EventCustomerOrderDetail.EventCustomerId : 0; var orderViewData = new OrderViewData { CreationMode = orderDetailOrganizationRoleUserCreator.SecondValue.SecondValue, CreatorName = orderDetailOrganizationRoleUserCreator.SecondValue.FirstValue, CreatorRole = orderDetailOrganizationRoleUserCreator.SecondValue.SecondValue, CustomerId = customer.CustomerId, CustomerName = customer.NameAsString, Description = description, EventCustomerId = eventCustomerId, OrderDetailDateCreated = orderDetailDateCreated, OrderDetailStatus = orderDetail.OrderItemStatus.Name, OrderDetailType = orderDetail.OrderItemStatus.ItemTypeName, Price = orderDetail.Price, Quantity = orderDetail.Quantity, ShippingDetails = GetShippingDetailUserPair(orderDetail.Id).ToList() }; if ((orderDetail.DetailType == OrderItemType.EventPackageItem || orderDetail.DetailType == OrderItemType.EventTestItem) && orderDetail.SourceCodeOrderDetail != null) { orderViewData.SourceCode = GetSourceCodeUserPair(orderDetail.SourceCodeOrderDetail); } return(orderViewData); }
public abstract bool UpdateOrderDetailsDAL(OrderDetail updateOrder);
/// <summary> /// Add method. /// </summary> /// <param name="orderDetail"></param> /// <returns></returns> public OrderDetail Add(OrderDetail orderDetail) { var orderDetailDac = new OrderDetailDAC(); return(orderDetailDac.Create(orderDetail)); }
public bool AddNewOrderDetail(OrderDetail order) { return(this.odao.AddNewOrderDetail(order)); }
//Methods public abstract bool AddOrderDetailsDAL(OrderDetail newOrder);
public bool DelOrderDetail(OrderDetail order) { return(this.odao.DelOrderDetail(order)); }
public bool AltOrderDetail(OrderDetail order) { return(this.odao.AltOrderDetail(order)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { NVAPICaller payPalcaller = new NVAPICaller(); string retMsg = ""; string token = ""; string PayerID = ""; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); bool ret = payPalcaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; var myOrder = new Order(); myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); myOrder.UserName = User.Identity.Name; myOrder.FirstName = decoder["FIRSTNAME"].ToString(); myOrder.LastName = decoder["LASTNAME"].ToString(); myOrder.Address = decoder["SHIPTOSTREET"].ToString(); myOrder.City = decoder["SHIPTOCITY"].ToString(); myOrder.State = decoder["SHIPTOSTATE"].ToString(); myOrder.PostalCode = decoder["SHIPTOZIP"].ToString(); myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString(); myOrder.Email = decoder["EMAIL"].ToString(); myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString()); try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmountFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmountFromPayPal) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } } catch (Exception) { Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch."); } ProductContext _db = new ProductContext(); _db.Orders.Add(myOrder); _db.SaveChanges(); using (Sklep.Logic.ShoppingCartActions usersShoppingCart = new Sklep.Logic.ShoppingCartActions()) { List <CartItem> myOrderList = usersShoppingCart.GetCartItems(); for (int i = 0; i < myOrderList.Count; i++) { var myOrderDetail = new OrderDetail(); myOrderDetail.OrderId = myOrder.OrderId; myOrderDetail.UserName = User.Identity.Name; myOrderDetail.ProductId = myOrderList[i].ProductId; myOrderDetail.Quantity = myOrderList[i].Quantity; myOrderDetail.UnitPrice = myOrderList[i].Product.UnitPrice; _db.OrderDetails.Add(myOrderDetail); _db.SaveChanges(); } Session["currentOrderId"] = myOrder.OrderId; List <Order> orderList = new List <Order>(); orderList.Add(myOrder); ShipInfo.DataSource = orderList; ShipInfo.DataBind(); OrderItemList.DataSource = myOrderList; OrderItemList.DataBind(); } } else { Response.Redirect("CheckoutError.aspx?" + retMsg); } } }
protected void btnCreateOrder_Click(object sender, EventArgs e) { int orderQty = 0; decimal totalAmount = 0, discountAmount = 0; string customerID = txtCustomerID.Text; decimal taxPercentage = Convert.ToDecimal(txtTax.Text); //============ Detail Data Preparation ============ ProductDiscountController productDiscountController = new ProductDiscountController(); List <OrderDetail> lst_OrderDetailInfo = new List <OrderDetail>(); List <CartInfo> lstCart = GettingJson(customerID); foreach (CartInfo obj in lstCart) { if (obj.Quantity > 0) { orderQty += obj.Quantity; discountAmount = productDiscountController.GetDiscountByProductID(obj.ProductID); OrderDetail obj_OrderDetail = new OrderDetail(); obj_OrderDetail.ProductID = obj.ProductID; obj_OrderDetail.Quantity = obj.Quantity; obj_OrderDetail.Price = obj.ProductPrice; obj_OrderDetail.DiscountAmount = discountAmount; lst_OrderDetailInfo.Add(obj_OrderDetail); totalAmount += obj.Quantity * (obj.ProductPrice - discountAmount); } } decimal commercialTax = decimal.Round(totalAmount * (taxPercentage / 100), 2); string[] selectedValue = (ddlTownship.Items[ddlTownship.SelectedIndex].Value).Split('-'); decimal deliveryCharges = Convert.ToDecimal(selectedValue[1]); //============ Header Data Preparation ============ OrderInfo obj_OrderInfo = new OrderInfo(); obj_OrderInfo.OrderDate = DateTime.Now; obj_OrderInfo.OrderQuantity = orderQty; obj_OrderInfo.Tax = commercialTax; //When I get directly from lable, I can't get last changes amount. obj_OrderInfo.DiscountAmount = Convert.ToDecimal(0); //Will add control later. obj_OrderInfo.DeliveryCharges = deliveryCharges; obj_OrderInfo.OrderAmount = totalAmount + commercialTax + deliveryCharges; //When I get directly from lable, I can't get last changes amount. obj_OrderInfo.OrderDescription = txtOrderDescription.Text; obj_OrderInfo.OrderStatus = "Created"; obj_OrderInfo.CustomerID = customerID; //============ Insert Data ============ OrderController orderControl = new OrderController(); OrderInfo return_OrderInfo = orderControl.InsertOrder(obj_OrderInfo); if (return_OrderInfo != null) { OrderDetailController orderDetailControl = new OrderDetailController(); orderDetailControl.InsertOrderDetail(return_OrderInfo.OrderID, lst_OrderDetailInfo); //============ Delete Json File ============ File.Delete(Server.MapPath("~/CartJson/" + customerID + "_cart.json")); } Response.Redirect("OrderInfoList.aspx"); #region +++ When you want to get data from Listview +++ ////for (int i = 0; i < productList.Items.Count; i++) ////{ //// Label lblProductID = (Label)productList.Items[i].FindControl("lbl_ProductID"); //// string productID = lblProductID.Text; ////} #endregion }