//******took out the int? id for now for testing //GET: AddToOrder public IActionResult AddToOrder(int?id) { /*if (id == null) * { * return View("Error", new string[] { "You must specify an order to add!" }); * }*/ //Creating a new customer order //Booleans are automatically false CustomerOrder cust_ord = new CustomerOrder() { CustomerOrderStatus = false }; CustomerOrder cod = _context.CustomerOrders.Find(id); if (cod == null) { return(View("Error", new string[] { "Order not found!" })); } //Creating a new order detail CustomerOrderDetail cd = new CustomerOrderDetail() { CustomerOrder = cod }; ViewBag.AllCustomerBooks = GetAllCustomerBooks(); //Change the view to make sure there's no list that requires something to be passed to it return(View("AddToOrder", cd)); }
public ResponseBaseModel Post([FromBody] CustomerOrderDetail orderDetail) { var model = new ResponseBaseModel { IsSuccess = false }; try { _updateCustomerPackageService.ChangePackage(orderDetail); model.Message = "Successfully updated"; model.IsSuccess = true; } catch (InvalidAddressException exception) { _logger.Error("Invalid Address or Email Address", exception); model.Message = exception.Message; } catch (DuplicateObjectException <ZipCode> exception) { _logger.Error("Zip code Error", exception); model.Message = "Zip code has some problem"; } catch (Exception exception) { _logger.Error(string.Format("While saving order for customerid ={0} and EverntId= {1} Exception Message {2} \n stack trace {3}", orderDetail.CustomerId, orderDetail.EventId, exception.Message, exception.StackTrace)); model.Message = exception.Message; } return(model); }
public ShippingDetail GetShippingDetailData(CustomerOrderDetail customerOrderDetail) { var option = customerOrderDetail.ShippingOptions.FirstOrDefault(); if (option == null) { return(null); } var shippingDetail = new ShippingDetail { ShippingOption = new ShippingOption(option.Id), DataRecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = _organizationRoleUserRepository.GetOrganizationRoleUser(_creatorOrganizationRoleUser), DateCreated = DateTime.Now, DateModified = DateTime.Now }, Status = ShipmentStatus.Processing, ShippingAddress = GetShippinAddress(customerOrderDetail), ActualPrice = option.Price }; return(shippingDetail); }
public IActionResult AddToOrder(CustomerOrderDetail cod, int SelectedBook) { //Change it select the book id from details/the list //find the product associated with the selected product id Book book = _context.Books.Find(SelectedBook); //set the order detail's book equal to the book we just found cod.Book = book; //find the order based on the id and the property is pending //Set this status equal to false //**False will mean "Pending" and True will mean "Finished" CustomerOrder reg = _context.CustomerOrders.Find(cod.CustomerOrder.CustomerOrderID); //set the order detail's order equal to the order we just found cod.CustomerOrder = reg; //set the book price for this detail equal to the current book fee cod.ProductPrice = cod.Book.Price; //add total fees cod.ExtendedPrice = cod.Quantity * cod.ProductPrice; if (ModelState.IsValid) { _context.CustomerOrderDetails.Add(cod); _context.SaveChanges(); return(RedirectToAction("Details", new { id = cod.CustomerOrder.CustomerOrderID })); } return(View(cod)); }
internal static ShoppingCart_V02 GetShoppingCart(int cartID, DateTime lastUpdated, string locale, int deliveryOptionID, OrderCategoryType orderCategory, DeliveryOptionType deliveryOption, int shippingAddressID, string distributorID, string freightCode, string orderSubType) { var itemList = new ShoppingCartItemList { new ShoppingCartItem_V01() }; var orderDetail = new CustomerOrderDetail(); return(new ShoppingCart_V02(cartID, lastUpdated, locale, deliveryOptionID, orderCategory, deliveryOption, shippingAddressID, itemList, distributorID, freightCode, orderSubType, orderDetail)); }
public MyHLShoppingCart InsertShoppingCart(string distributorID, string locale, ServiceProvider.CatalogSvc.OrderCategoryType orderCategory, Shipping.ShippingInfo shippingInfo, CustomerOrderDetail customerOrderDetail, bool isDraft, string draftName) { return(Providers.ShoppingCartProvider.InsertShoppingCart(distributorID, locale, orderCategory, shippingInfo, customerOrderDetail, isDraft, draftName)); }
public CustomerOrderDetail GetCustomerOrderDetails(long customerId, long eventId) { var order = _orderRepository.GetOrder(customerId, eventId); var customerProfile = _customerRepository.GetCustomer(customerId); if (customerProfile == null) { return(null); } var eventPackages = _eventPackageRepository.GetPackagesForEvent(eventId); var eventTests = _eventTestRepository.GetTestsForEvent(eventId); var customerOrder = new CustomerOrderDetail { OrderId = order.Id, EventId = eventId, CustomerId = customerId }; var orderPackage = order.OrderDetails.FirstOrDefault(o => o.DetailType == OrderItemType.EventPackageItem && o.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess); if (orderPackage != null) { var eventPackage = eventPackages.SingleOrDefault(x => x.Id == orderPackage.OrderItem.ItemId); customerOrder.PackageModel = GetEventPackage(eventPackage); } var orderTests = order.OrderDetails.Where(o => o.DetailType == OrderItemType.EventTestItem && o.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess).ToList(); if (orderTests != null) { var testIds = orderTests.Select(s => s.OrderItem.ItemId).ToArray(); var evemtTest = eventTests.Where(et => testIds.Contains(et.Id)); customerOrder.AlaCarteTests = GetTestModels(evemtTest); } var product = order.OrderDetails.Where(od => od.OrderItemStatus.OrderStatusState == OrderStatusState.FinalSuccess && od.OrderItem.OrderItemType == OrderItemType.ProductItem).Select(od => od.OrderItem.ItemId).FirstOrDefault(); customerOrder.ProductId = product; var shippingDetailIds = order.OrderDetails.SelectMany(od => od.ShippingDetailOrderDetails.Where(sdod => sdod.IsActive).Select(sdod => sdod.ShippingDetailId)).ToArray(); if (shippingDetailIds.Any()) { var shipingDetails = _shippingDetailRepository.GetByIds(shippingDetailIds).ToList(); customerOrder.ShippingOptions = shipingDetails.Select(x => new ShippingOptionDetail { Id = x.Id }).ToArray(); } return(customerOrder); }
internal static ShoppingCart_V02 GetShoppingCart(int cartID, DateTime lastUpdated, string locale, int deliveryOptionID, MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.OrderCategoryType orderCategory, MyHerbalife3.Ordering.ServiceProvider.CatalogSvc.DeliveryOptionType deliveryOption, int shippingAddressID, string distributorID, string freightCode, string orderSubType) { var itemList = new ShoppingCartItemList { new ShoppingCartItem_V01() }; var orderDetail = new CustomerOrderDetail(); return(new ShoppingCart_V02() { ShoppingCartID = cartID, LastUpdated = lastUpdated, Locale = locale, DeliveryOptionID = deliveryOptionID, OrderCategory = orderCategory, DeliveryOption = deliveryOption, ShippingAddressID = shippingAddressID, CartItems = itemList, DistributorID = distributorID, FreightCode = freightCode, OrderSubType = orderSubType, CustomerOrderDetail = orderDetail }); }
private Address GetShippinAddress(CustomerOrderDetail customerOrderDetail) { var customer = _customerRepository.GetCustomer(customerOrderDetail.CustomerId); var shippingAddress = customer.Address; if (customerOrderDetail.ShippingAddresss != null) { shippingAddress = Mapper.Map <AddressEditModel, Address>(customerOrderDetail.ShippingAddresss); } //Create new address for shipping shippingAddress.Id = 0; return(shippingAddress); }
public CustomerOrderDetail Get([FromUri] long customerId, [FromUri] long eventId) { CustomerOrderDetail model; try { model = _orderBuilderService.GetCustomerOrderDetails(customerId, eventId); model.IsSuccess = true; } catch (Exception exception) { model = new CustomerOrderDetail(); _logger.Error(string.Format("While getting order for customerid ={0} and EverntId= {1} Exception Message {2} \n stack trace {3}", customerId, eventId, exception.Message, exception.StackTrace)); } return(model); }
/// <summary> /// The get customer order details. /// </summary> /// <param name="custOrder"> /// The cust order. /// </param> /// <returns> /// </returns> private static CustomerOrderDetail getCustomerOrderDetails(CustomerOrder_V01 custOrder) { var orderDetail = new CustomerOrderDetail(); orderDetail.CustomerOrderID = custOrder.OrderID; orderDetail.EmailAddress = custOrder.EmailAddress; orderDetail.FirstName = ((CustomerShippingInfo_V01)custOrder.Shipping).Recipient.First; orderDetail.LastName = ((CustomerShippingInfo_V01)custOrder.Shipping).Recipient.Last; orderDetail.MiddleName = ((CustomerShippingInfo_V01)custOrder.Shipping).Recipient.Middle; orderDetail.OrderDate = custOrder.Created; orderDetail.CustomerPaymentPreference = custOrder.PaymentMethodChoice.ToString(); orderDetail.ContactPreference = "HL"; orderDetail.Telephone = ((CustomerShippingInfo_V01)custOrder.Shipping).Phone; orderDetail.CustomerComments = custOrder.CustomerNote; return(orderDetail); }
public IActionResult Edit(CustomerOrderDetail orderDetail) { //Find the related order detail in the database CustomerOrderDetail DbOrdDet = _context.CustomerOrderDetails.Include(o => o.Book).Include(o => o.CustomerOrder). FirstOrDefault(o => o.CustomerOrderDetailID == orderDetail.CustomerOrderDetailID); //update the related fields DbOrdDet.Quantity = orderDetail.Quantity; DbOrdDet.ProductPrice = DbOrdDet.Book.Price; DbOrdDet.ExtendedPrice = DbOrdDet.ProductPrice * DbOrdDet.Quantity; //update the database _context.CustomerOrderDetails.Update(DbOrdDet); _context.SaveChanges(); //return to the order details return(RedirectToAction("Details", "CustomerOrders", new { id = DbOrdDet.CustomerOrder.CustomerOrderID })); }
private void createNewTab(eTabType type) { switch (type) { case eTabType.MAIN_TAB: break; case eTabType.CUSTOMER_TAB: { //Hieu //Edit var newTab = isExitTabPage("Danh sách khách hàng"); if (newTab == null) { newTab = new TabPage("Danh sách khách hàng"); var customerList = new CustomerList(); customerList.Dock = DockStyle.Fill; newTab.Controls.Add(customerList); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.VENDOR_TAB: { var newTab = isExitTabPage("Danh sách nhà cung cấp"); if (newTab == null) { newTab = new TabPage("Danh sách nhà cung cấp"); var vendorList = new VendorList(); vendorList.Dock = DockStyle.Fill; newTab.Controls.Add(vendorList); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.ORDER_TAB: { var customerOrder = new CreateCustomerOrderForm(); var result = customerOrder.ShowDialog(); if (result == DialogResult.OK) { var newTab = isExitTabPage("Giao dịch"); if (newTab == null) { newTab = new TabPage("Giao dịch"); newTab.AutoScroll = true; var order = new OrderDetailForm(customerOrder.OrderId); order.Dock = DockStyle.Top; newTab.Controls.Add(order); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; } else if (result == DialogResult.Retry) { createNewTab(eTabType.CUSTOMER_TAB); } break; } case eTabType.CUSTOMER_ORDER_LIST_TAB: { var selectForm = new SelectOrderForm(); var result = selectForm.ShowDialog(); if (result == DialogResult.OK) { var text = "Đơn hàng " + selectForm.OrderKey; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var order = new CustomerOrderDetail(selectForm.OrderId); order.Dock = DockStyle.Fill; newTab.Controls.Add(order); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; } break; } case eTabType.STORE_TAB: { var text = "Danh sách kho hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var store = new InventoryList(); store.Dock = DockStyle.Fill; newTab.Controls.Add(store); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.PRODUCT_TAB: { var text = "Danh sách mặt hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var product = new ProductList(); product.Dock = DockStyle.Fill; newTab.Controls.Add(product); this.newProductMenuItem.Click += product.showDialogAddProduct; //7ung tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.STAFF_TAB: { var text = "Danh sách nhân viên"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var staff = new StaffList(); staff.Dock = DockStyle.Fill; newTab.Controls.Add(staff); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.INOUT_INVENTORY: { var text = "Quản lý đơn hàng nhập xuất kho"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var store = new InOutInventoryList(); store.Dock = DockStyle.Fill; newTab.Controls.Add(store); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.INVENTORY_LIST: { var text = "Quản lý kho hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var store = new InventoryList(); store.Dock = DockStyle.Fill; newTab.Controls.Add(store); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.VENDOR_ORDER_TAB: { var vendorOrder = new CreateVendorOrderForm(); var result = vendorOrder.ShowDialog(); if (result == DialogResult.OK) { var text = "Giao dịch đơn hàng " + vendorOrder.DocumentKey; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var order = new VendorOrderDetailForm(vendorOrder.OrderId); order.Dock = DockStyle.Top; newTab.Controls.Add(order); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; } else if (result == DialogResult.Retry) { createNewTab(eTabType.VENDOR_TAB); } break; } case eTabType.VENDOR_ORDER_LIST_TAB: { var selectForm = new SelectVendorOrderForm(); var result = selectForm.ShowDialog(); if (result == DialogResult.OK) { var text = "Đơn hàng " + selectForm.DocumentKey; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var order = new VendorOrderDetail(selectForm.OrderId); order.DocumentKey = selectForm.DocumentKey; order.Dock = DockStyle.Fill; newTab.Controls.Add(order); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; } break; } case eTabType.REVENUE_REPORT_TAB: { var text = "Báo cáo doanh thu"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var report = new RevenueReport(); report.Dock = DockStyle.Fill; newTab.Controls.Add(report); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.CUSTOMER_REPORT_TAB: { var text = "Báo cáo tình hình khách hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var report = new CustomerReport(); report.Dock = DockStyle.Top; newTab.Controls.Add(report); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.CREATE_BUSINESS_REPORT_TAB: { var dialogCreate = new CreateReportForm(); var r = dialogCreate.ShowDialog(); if (r == DialogResult.OK) { var text = "Báo cáo chi phí bán hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var report = new CreateBusinessFee(dialogCreate.DocumentId, true); report.Dock = DockStyle.Top; newTab.Controls.Add(report); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; } break; } case eTabType.VIEW_BUSINESS_REPORT_TAB: { var text = "Xem cáo chi phí bán hàng"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var report = new ViewBusinessFee(); report.Dock = DockStyle.Top; newTab.Controls.Add(report); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } case eTabType.INVENTORY_REPORT_TAB: { var text = "Báo cáo tồn kho"; var newTab = isExitTabPage(text); if (newTab == null) { newTab = new TabPage(text); newTab.AutoScroll = true; var report = new InventoryReport(); report.Dock = DockStyle.Fill; newTab.Controls.Add(report); tabControl.TabPages.Add(newTab); } tabControl.SelectedTab = newTab; break; } default: break; } }
public void ChangePackage(CustomerOrderDetail customerOrderDetail) { using (var scope = new TransactionScope()) { if (customerOrderDetail.PaymentModel != null) { try { _customerPaymentService.ProcessPayment(customerOrderDetail.PaymentModel); } catch (Exception exception) { throw new Exception(exception.Message, exception); } } try { var eventid = customerOrderDetail.EventId; var customerid = customerOrderDetail.CustomerId; //var eventCustomer = _eventCustomerRepository.Get(eventid, customerid); var order = GetOrder(customerid, eventid); SourceCode sourceCode = null; if (customerOrderDetail.SourceCode != null) { sourceCode = new SourceCode { Id = customerOrderDetail.SourceCode.SourceCodeId, CouponCode = customerOrderDetail.SourceCode.SourceCode, CouponValue = customerOrderDetail.SourceCode.DiscountApplied } } ; IOrderController orderController = new OrderController(); var orderDetail = orderController.GetActiveOrderDetail(order); if (order == null || order.OrderDetails.IsEmpty()) { return; } ShippingDetail shippingDetails = null; if (customerOrderDetail.IsShippingPurchased && customerOrderDetail.ShippingOptions != null && customerOrderDetail.ShippingOptions.Any()) { shippingDetails = _patientShippingDetailFactory.GetShippingDetailData(customerOrderDetail); } var orderables = new List <IOrderable>(); var selectedTestIds = new List <long>(); if (customerOrderDetail.AlaCarteTests != null && customerOrderDetail.AlaCarteTests.Any()) { selectedTestIds = customerOrderDetail.AlaCarteTests.Select(x => x.TestId).ToList(); } long packageId = 0; if (customerOrderDetail.PackageModel != null && customerOrderDetail.PackageModel.PackageId > 0) { packageId = customerOrderDetail.PackageModel.PackageId; orderables.Add(_eventPackageRepository.GetByEventAndPackageIds(eventid, packageId)); selectedTestIds = RemoveTestsAlreadyInPackage(selectedTestIds, eventid, packageId); } if (!selectedTestIds.IsNullOrEmpty()) { var eventTests = _eventTestRepository.GetByEventAndTestIds(eventid, selectedTestIds); if (packageId > 0) { foreach (var eventTest in eventTests) { eventTest.Price = eventTest.WithPackagePrice; } } orderables.AddRange(eventTests); } ElectronicProduct product = null; if (customerOrderDetail.ProductId.HasValue && customerOrderDetail.ProductId.Value > 0) { var productIsAlreadyPurchased = order.OrderDetails.Any( x => x.DetailType == OrderItemType.ProductItem && x.OrderItem.ItemId == customerOrderDetail.ProductId.Value); if (!productIsAlreadyPurchased) { product = _electronicProductRepository.GetById(customerOrderDetail.ProductId.Value); orderables.Add(product); } } if (customerOrderDetail.IsShippingPurchased && shippingDetails != null) { IShippingController shippingController = new ShippingController(); var shippingDetail = shippingController.OrderShipping(shippingDetails); var shippingDetailOrderDetail = new ShippingDetailOrderDetail { Amount = shippingDetail.ActualPrice, IsActive = true, OrderDetailId = orderDetail.Id, ShippingDetailId = shippingDetail.Id }; _shippingDetailOrderDetailRepository.Save(shippingDetailOrderDetail); } var indentedLineItemsAdded = false; // TODO: applying hook to the system all the indented line items will be attached to the first order item. foreach (var orderable in orderables) { if (!indentedLineItemsAdded && (orderable.OrderItemType == OrderItemType.EventPackageItem || orderable.OrderItemType == OrderItemType.EventTestItem)) { _orderController.AddItem(orderable, 1, customerid, _creatorOrganizationRoleUser, sourceCode, null, null, OrderStatusState.FinalSuccess); indentedLineItemsAdded = true; } else { _orderController.AddItem(orderable, 1, customerid, _creatorOrganizationRoleUser, OrderStatusState.FinalSuccess); } } _orderController.PlaceOrder(order); if (shippingDetails != null) { SaveProductShippingDetail(product, orderDetail, shippingDetails); } scope.Complete(); } catch (Exception exception) { if (customerOrderDetail.PaymentModel == null) { throw new Exception("An Exception caused while saving the Order.", exception); } var paymentInstruments = customerOrderDetail.PaymentModel.Payments; var chargeCardPayment = paymentInstruments.ChargeCard ?? null; if (chargeCardPayment == null || paymentInstruments.Amount <= 0) { throw new Exception("An Exception caused while saving the Order.", exception); } var paymentGateway = IoC.Resolve <IPaymentProcessor>(); paymentGateway.VoidRequestforaPreviousResponse(chargeCardPayment.ChargeCardPayment.ProcessorResponse); throw new Exception("An Exception caused while saving the Order.", exception); } } }
/// <summary> /// SaveCustomerOrders - This method used to generate the order and return the order id /// </summary> /// <param name="userEmail"></param> /// <param name="orderId"></param> /// <returns></returns> public bool SaveCustomerOrders(string userEmail, out string orderId) { bool flag = false; orderId = string.Empty; try { List <CartEntity> cartInfo = new List <CartEntity>(); cartInfo = (from uc in context.UserCarts where uc.UserEmail == userEmail && uc.Active == true select new CartEntity { Id = uc.Id, UserEmail = uc.UserEmail, ProductName = uc.ProductName, ProductDescription = uc.ProductDescription, ProductSKU = uc.ProductSKU, Quantity = uc.Quantity, UnitRate = uc.UnitRate, MSRP = uc.Quantity * uc.UnitRate, UnitTotalCost = (uc.Quantity * uc.UnitRate) - (((uc.Quantity * uc.UnitRate) * uc.Discount) / 100), Discount = uc.Discount, CreatedDate = uc.CreatedDate } ).ToList(); decimal cartTotal = 0; int itemTotalQuantity = 0; foreach (var item in cartInfo) { cartTotal = cartTotal + item.UnitTotalCost ?? 0; itemTotalQuantity = itemTotalQuantity + item.Quantity ?? 0; } //var cartInfo = context.UserCarts.Where(x => x.UserEmail == userEmail && x.Active == true).ToList(); if (cartInfo != null) { CustomerOrder _customerOrder = new CustomerOrder(); string _orderId = Convert.ToString(Guid.NewGuid().ToString("N").Substring(0, 12)).ToUpper(); _customerOrder.OrderId = _orderId; _customerOrder.UserEmail = userEmail; _customerOrder.UserId = 1; _customerOrder.TotalCost = cartTotal; _customerOrder.TotalQuantity = itemTotalQuantity; _customerOrder.PaymentStatus = false; _customerOrder.CreatedDate = DateTime.UtcNow; _customerOrder.Active = true; writeContext.CustomerOrders.Add(_customerOrder); writeContext.SaveChanges(); foreach (var item in cartInfo) { CustomerOrderDetail _customerOrderDetails = new CustomerOrderDetail(); _customerOrderDetails.OrderId = _orderId; _customerOrderDetails.ProductName = item.ProductName; _customerOrderDetails.ProductSKU = item.ProductSKU; _customerOrderDetails.ProductDescription = item.ProductDescription; _customerOrderDetails.Quantity = item.Quantity; _customerOrderDetails.MSRP = item.MSRP; _customerOrderDetails.UnitRate = item.UnitRate; _customerOrderDetails.Discount = item.Discount; _customerOrderDetails.CreatedDate = DateTime.UtcNow; _customerOrderDetails.Active = true; writeContext.CustomerOrderDetails.Add(_customerOrderDetails); writeContext.SaveChanges(); } flag = true; orderId = _orderId; } } catch (Exception) { } return(flag); }