public List <OrderLineModel> ReadOrderLines() { try { OpenSqlConnection(); CreateCommandSc("SelectAllOrderLines"); SqlDataReader sqlDataReader = GetExecuteReader(); List <OrderLineModel> productList = new List <OrderLineModel>(); while (sqlDataReader.Read()) { OrderLineModel orderLineModel = new OrderLineModel(); orderLineModel.OrderLineId = Convert.ToInt32(sqlDataReader["OrderLineId"]); orderLineModel.OrderId = Convert.ToInt32(sqlDataReader["OrderId"]); orderLineModel.ProductId = Convert.ToInt32(sqlDataReader["ProductId"]); orderLineModel.Quantity = Convert.ToInt32(sqlDataReader["Quantity"]); productList.Add(orderLineModel); } return(productList); } catch (SqlException ex) { throw new System.Exception(ex.Message); } finally { CloseSqlConnection(); } }
//Update Order Data public static void UpdateOrderLine(int orderLineId, int orderID, int partId, int serviceId, int lineNo, string lineDescription, int serviceQty, int partQty, string status, string orderNotes) { OrderLineModel data = new OrderLineModel { OrderLineId = orderLineId, OrderId = orderID, PartId = partId, ServiceId = serviceId, LineNo = lineNo, LineDescription = lineDescription, ServiceQty = serviceQty, PartQty = partQty, Status = status, OrderNotes = orderNotes }; //create SQL Query string sql = @"Update dbo.[OrderLine] SET OrderId = @OrderId, PartId = @PartId, ServiceId = @ServiceId, LineNo = @LineNo, LineDescription = @LineDescription, ServiceQty = @ServiceQty, PartQty = @PartQty, Status = @Status, OrderNotes = @OrderNotes Location = @Location, Status = @Status WHERE OrderLineId = @OrderLineId;"; SqlDataAccess.UpdateData(sql, data); }
/// <summary> /// Validates the supplied input line against the supplied order /// </summary> private ServiceResponse <int> ValidateOrderLine(OrderModel order, OrderLineModel line, string publicErrorMessage) { if (order.Lines == null) { order.Lines = new List <OrderLineModel>(); } if (order.Lines.Where(l => l.Id == line.Id).Count() > 1) { LogError(nameof(UpdateOrderLine), publicErrorMessage, $"{order.Lines.Where(l => l.Id == line.Id).Count()} duplicate line matches found for order line id {line.Id}"); return(new ServiceResponse <int>(ServiceError.InternalServerError, publicErrorMessage)); } if (order.Lines.All(l => l.Id != line.Id)) { if (order.Lines.Any(l => l.Sku.Id == line.Sku.Id)) { return(new ServiceResponse <int>(ServiceError.BadRequest, $"Order already contains a line with Sku Code {line.Sku.Id}")); } var skuValidationResponse = ValidateNewLineSku(order.Id, line.Sku.Id, publicErrorMessage); if (!skuValidationResponse.IsSuccessful) { return(skuValidationResponse); } } return(new ServiceResponse <int>()); }
/// <summary> /// Fill Order Model from CSV file all lines /// </summary> /// <param name="allLines">All lines of CSV file</param> /// <returns></returns> private OrderModel FillModelFromCSVLines(List <string> allLines) { OrderModel orderModel = new OrderModel(); allLines.RemoveAt(0); orderModel.OrderLines = new List <OrderLineModel>(); foreach (var line in allLines) { List <string> lineItem = line.Split('|').ToList(); lineItem.RemoveAt(12); lineItem.RemoveAt(0); orderModel.OrderNumber = int.Parse(lineItem[0]); orderModel.OrderDate = DateTime.Parse(lineItem[8]); orderModel.Product = new ProductModel(); orderModel.Product.ProductGroup = lineItem[7]; orderModel.Product.ProductNumber = lineItem[2]; OrderLineModel orderLine = new OrderLineModel(); orderLine.OrderLineNumber = int.Parse(lineItem[1]); orderLine.Quantity = int.Parse(lineItem[3]); orderLine.Name = lineItem[4]; orderLine.Description = lineItem[5]; orderLine.Price = Double.Parse(lineItem[6]); orderLine.Customer = new CustomerModel(); orderLine.Customer.CustomerName = lineItem[9]; orderLine.Customer.CustomerName = lineItem[10]; orderModel.OrderLines.Add(orderLine); } return(orderModel); }
public void InsertOrderLine(OrderLineModel orderLineModel) { using (var context = new WebShopContext()) { context.OrderLineModel.Add(orderLineModel); context.SaveChanges(); } }
internal void DeleteAllOrderLine(OrderLineModel OrderLineposData) { while (this.DeleteResultBannerIfAlreadyExists(OrderLineposData)) { ; } //this.ClearFilter(); }
public ActionResult UpdateLine(OrderLineModel model) { if (ModelState.IsValid) { UpdateOneOrderLine(model.OrderLineId, model.OrderId, model.PartId, model.ServiceId, model.LineNo, model.LineDescription, model.ServiceQty, model.PartQty, model.Status, model.OrderNotes, model.PartName, model.ServiceName); } return(RedirectToAction("OrderDetailByID", new { id = model.OrderId })); }
internal void Update(OrderLineModel data) { if (data.Status != null) { Element.ScrolTo(StatusDD); Select.ByText(StatusDD, data.Status); Wait.MLSeconds(100); } this.Save(); }
public bool Insert(OrderLineModel orderLineModel) { try { orderLineData.InsertOrderLine(orderLineModel); return(true); } catch (Exception) { throw; } }
public void OrderMapper_Outbound_MapsSkuPropertiesFromServiceOrderLineModel() { // Arrange var serviceModel = new OrderLineModel(2, new SkuModel("3", "Sku3")); // Act var result = _target.Map <OrderLineModel, OrderLine>(serviceModel); // Assert Assert.AreEqual(serviceModel.Sku.Id, result.SkuCode); Assert.AreEqual(serviceModel.Sku.DisplayName, result.SkuDisplayName); }
internal bool DeleteResultBannerIfAlreadyExists(OrderLineModel orderLineModel) { var oldOrderLine = this.SearchOrderLine(orderLineModel.SearchTerm, orderLineModel.ProductInformation); if (oldOrderLine != null) { this.DeleteRow(oldOrderLine); return(true); } else { return(false); } }
internal void OpenOrderLine(OrderLineModel data) { var oldOrderLine = this.SearchOrderLine(data.SearchTerm, data.ProductInformation); if (oldOrderLine != null) { oldOrderLine.Click(); Wait.AM_Loaging_ShowAndHide(); } else { throw new Exception("No Add Found Related to Given Information."); } }
public ActionResult CreateLine(OrderLineModel model) { if (ModelState.IsValid) { //Note: When calling a method, the order of the parameters is very important int recordsCreated = CreateOrderLine(model.OrderLineId, model.OrderId, model.PartId, model.ServiceId, model.LineNo, model.LineDescription, model.ServiceQty, model.PartQty, model.Status, model.OrderNotes, model.PartName, model.ServiceName); return(RedirectToAction("OrderDetailByID", new { id = model.OrderId })); } ViewBag.Message = "Order Detail"; return(View()); }
public void OrderMapper_Outbound_MapsPropertiesFromServiceOrderLineModelByName() { // Arrange var serviceModel = new OrderLineModel(2, new SkuModel(string.Empty, string.Empty)) { SortOrder = 3, Quantity = 5 }; // Act var result = _target.Map <OrderLineModel, OrderLine>(serviceModel); // Assert Assert.AreEqual(serviceModel.Id, result.Id); Assert.AreEqual(serviceModel.SortOrder, result.SortOrder); Assert.AreEqual(serviceModel.Quantity, result.Quantity); }
public void OrderMapper_Outbound_MapsSingleOrderLine() { // Arrange var serviceLineModel = new OrderLineModel(2, new SkuModel(string.Empty, string.Empty)); var serviceOrderModel = new OrderModel(0) { Lines = new List <OrderLineModel> { serviceLineModel } }; // Act var result = _target.Map <OrderModel, Order>(serviceOrderModel); // Assert Assert.AreEqual(serviceOrderModel.Lines.Count, result.Lines.Count); Assert.AreEqual(serviceLineModel.Id, result.Lines.First().Id); }
public static void UpdateOneOrderLine(int orderLineId, int orderId, int?partId, int?serviceId, int lineNo, string lineDescription, int?serviceQty, int?partQty, string status, string orderNote, string partName, string serviceName) { //In case of the values being null sets the values var partId2 = (int?)partId; if (partId2 == null) { partId = 0; } var serviceId2 = (int?)serviceId; if (serviceId2 == null) { serviceId = 0; } OrderLineModel data = new OrderLineModel { OrderLineId = orderLineId, OrderId = orderId, PartId = partId, ServiceId = serviceId, LineNo = lineNo, LineDescription = lineDescription, ServiceQty = serviceQty, PartQty = partQty, Status = status, OrderNotes = orderNote, PartName = partName, ServiceName = serviceName }; //create SQL Query string sql = @"Update dbo.[OrderLine] SET OrderId = @OrderId, PartId = @PartId, ServiceId = @ServiceId, [LineNo] = @LineNo, LineDescription = @LineDescription, ServiceQty = @ServiceQty, PartQty = @PartQty, [Status] = @Status, OrderNotes = @OrderNotes WHERE OrderLineId = @OrderLineId;"; SqlDataAccess.UpdateData(sql, data); }
//Create new Order public static int CreateOrderLine(int orderLineId, int orderId, int?partId, int?serviceId, int lineNo, string lineDescription, int?serviceQty, int?partQty, string status, string orderNotes, string partName, string serviceName) { //In case of the values being null sets the values var partId2 = (int?)partId; if (partId2 == null) { partId = 0; } var serviceId2 = (int?)serviceId; if (serviceId2 == null) { serviceId = 0; } OrderLineModel data = new OrderLineModel { OrderLineId = orderLineId, OrderId = orderId, PartId = partId, ServiceId = serviceId, LineNo = lineNo, LineDescription = lineDescription, ServiceQty = serviceQty, PartQty = partQty, Status = status, OrderNotes = orderNotes, PartName = partName, ServiceName = serviceName }; string sqlBody = @"INSERT INTO dbo.[OrderLine] (dbo.[OrderLine].[OrderId], dbo.[OrderLine].[PartId], dbo.[OrderLine].[ServiceId], dbo.[OrderLine].[LineNo], [LineDescription], [ServiceQty], [PartQty], [Status], [OrderNotes]) VALUES (@OrderId, @PartId, @ServiceId, @LineNo, @LineDescription, @ServiceQty, @PartQty, @Status, @OrderNotes);"; return(SqlDataAccess.SaveData(sqlBody, data)); }
public void UpdateOrderLine(OrderLineModel orderLineModel) { using (var context = new WebShopContext()) { var result = context.OrderLineModel.SingleOrDefault(b => b.OrderLineId == orderLineModel.OrderLineId); if (result != null) { try { context.OrderLineModel.Attach(orderLineModel); context.Entry(orderLineModel).State = EntityState.Modified; context.SaveChanges(); } catch (Exception ex) { throw; } } } }
public void OrderMapper_Outbound_MapsMultipleOrderLines() { // Arrange var serviceLineModel1 = new OrderLineModel(1, new SkuModel(string.Empty, string.Empty)); var serviceLineModel2 = new OrderLineModel(2, new SkuModel(string.Empty, string.Empty)); var serviceOrderModel = new OrderModel(0) { Lines = new List <OrderLineModel> { serviceLineModel1, serviceLineModel2 } }; // Act var result = _target.Map <OrderModel, Order>(serviceOrderModel); // Assert Assert.AreEqual(serviceOrderModel.Lines.Count, result.Lines.Count); Assert.IsTrue(result.Lines.Any(line => line.Id == serviceLineModel1.Id)); Assert.IsTrue(result.Lines.Any(line => line.Id == serviceLineModel2.Id)); }
public void InsertOrderLine(OrderLineModel orderLineModel) { try { OpenSqlConnection(); SqlCommand sqlCommand = CreateCommandSc("InsertOrderLine"); sqlCommand.Parameters.Add(new SqlParameter("@OrderId", orderLineModel.OrderId)); sqlCommand.Parameters.Add(new SqlParameter("@ProductId", orderLineModel.ProductId)); sqlCommand.Parameters.Add(new SqlParameter("@Quantity", orderLineModel.Quantity)); ExecutedNonQuery(); } catch (SqlException ex) { throw new System.Exception(ex.Message); } finally { CloseSqlConnection(); } }
public CheckoutModel ProductToCard(string sessionKey, List <ProductModel> productFromSessionCard) { int userId = Convert.ToInt32(sessionKey); decimal totalPrice = productFromSessionCard.Sum(p => p.SessionPrice); int orderId = OrderToBase(userId, totalPrice); using (var context = new WebShopContext()) { foreach (ProductModel item in productFromSessionCard) { OrderLineModel orderline = new OrderLineModel(orderId, item.ProductId, item.SessionQuantity, item.SessionPrice); context.OrderLineModel.Add(orderline); } context.SaveChanges(); CheckoutModel checkoutModel = new CheckoutModel(); checkoutModel.orderLines = context.OrderLineModel.Where(p => p.OrderId == orderId).ToList(); checkoutModel.order = context.OrdersModel.Where(p => p.OrderId == orderId).FirstOrDefault(); checkoutModel.user = context.UserModel.Where(p => p.UserId == userId).FirstOrDefault(); return(checkoutModel); } }
public ActionResult UpdateLine(int id) { ViewBag.Id = id; //Get ID Value For Later Reuse var resultModel = LoadOneLine(id); OrderLineModel orderModel = new OrderLineModel(); orderModel.OrderLineId = resultModel.OrderLineId; orderModel.OrderId = resultModel.OrderId; orderModel.PartId = resultModel.PartId; orderModel.ServiceId = resultModel.ServiceId; orderModel.LineNo = resultModel.LineNo; orderModel.LineDescription = resultModel.LineDescription; orderModel.ServiceQty = resultModel.ServiceQty; orderModel.PartQty = resultModel.PartQty; orderModel.Status = resultModel.Status; orderModel.OrderNotes = resultModel.OrderNotes; orderModel.PartName = resultModel.PartName; orderModel.ServiceName = resultModel.ServiceName; //--------------------------------------------- return(View(orderModel)); }
public OrderModel GetOrderModelFromXML(XElement matchElement, OrderModel order) { order = new OrderModel(); XElement element = matchElement.Parent; order.OrderNumber = int.Parse(element.Element("OrderNumber").Value); order.OrderDate = DateTime.Parse(element.Element("OrderDate").Value); order.Product = new ProductModel(); foreach (XElement eleProduct in element.Descendants("Product")) { order.Product.ProductNumber = eleProduct.Element("ProductNumber").Value; order.Product.ProductGroup = eleProduct.Element("ProductGroup").Value; } order.OrderLines = new List <OrderLineModel>(); foreach (XElement eleOrderLine in element.Descendants("OrderLineModel")) { OrderLineModel orderLine = new OrderLineModel(); orderLine.OrderLineNumber = int.Parse(eleOrderLine.Element("OrderLineNumber").Value); orderLine.Name = eleOrderLine.Element("Name").Value; orderLine.Description = eleOrderLine.Element("Description").Value; orderLine.Price = Double.Parse(eleOrderLine.Element("Price").Value); orderLine.Quantity = int.Parse(eleOrderLine.Element("Quantity").Value); orderLine.Customer = new CustomerModel(); foreach (XElement eleCustomer in element.Descendants("Customer")) { orderLine.Customer.CustomerName = eleCustomer.Element("CustomerName").Value; orderLine.Customer.CustomerNumber = int.Parse(eleCustomer.Element("CustomerNumber").Value); } order.OrderLines.Add(orderLine); } return(order); }
//Create New Order Line public static int CreateOrderLine(int orderLineId, int orderID, int partId, int serviceId, int lineNo, string lineDescription, int serviceQty, int partQty, string status, string orderNotes) { OrderLineModel data = new OrderLineModel { OrderLineId = orderLineId, OrderId = orderID, PartId = partId, ServiceId = serviceId, LineNo = lineNo, LineDescription = lineDescription, ServiceQty = serviceQty, PartQty = partQty, Status = status, OrderNotes = orderNotes }; string sql = @"insert into dbo.[OrderLine] (OrderId, PartId, ServiceId, LineNo, LineDescription, ServiceQty, PartQty, Status, OrderNotes) values (@OrderId, @PartId, @ServiceId, @LineNo, @LineDescription, @ServiceQty, @PartQty, @Status, @OrderNotes);"; return SqlDataAccess.SaveData(sql, data); }
/// <inheritdoc /> public ServiceResponse <int> UpdateOrderLine(int orderId, OrderLineModel line) { var publicErrorMessage = $"Error saving order with id {orderId}"; try { var orderResponse = GetOrder(orderId); if (!orderResponse.IsSuccessful) { return(new ServiceResponse <int>(orderResponse.ServiceError, orderResponse.ErrorMessages.ToArray())); } var order = orderResponse.Data; var lineValidationResponse = ValidateOrderLine(order, line, publicErrorMessage); if (!lineValidationResponse.IsSuccessful) { return(lineValidationResponse); } // Add a new line if (order.Lines.All(l => l.Id != line.Id)) { order.Lines.Add(line); var repoOrder = _repository.Save(order); return(new ServiceResponse <int>(repoOrder.Lines.First(l => l.Sku.Id == line.Sku.Id).Id)); } // update an existing line order.Lines.First(l => l.Id == line.Id).Quantity = line.Quantity; _repository.Save(orderResponse.Data); return(new ServiceResponse <int>(line.Id)); } catch (Exception e) { LogError(nameof(UpdateOrderLine), publicErrorMessage, $"{e.Message} StackTrace: {e.StackTrace}"); return(new ServiceResponse <int>(ServiceError.InternalServerError, publicErrorMessage)); } }
public void Update(OrderLineModel orderLineModel) { orderLineData.UpdateOrderLine(orderLineModel); }
public EditOrderLinePage FillOrderLine_Sales(OrderLineModel OrderLineData) { Wait.UntilDisply(PositionDD); Select.ByText(ProductGroupDD, OrderLineData.ProductGroup); Wait.MLSeconds(200); Select.ByText(AddTypeDD, OrderLineData.AddType); Wait.MLSeconds(1000); if (OrderLineData.Position != null && OrderLineData.Position != 0) { Select.ByText(PositionDD, OrderLineData.Position.ToString()); Wait.MLSeconds(200); } if (OrderLineData.SearchTerm != null && OrderLineData.SearchTerm != "") { SelectSearchTerms(OrderLineData.SearchTerm); } if (OrderLineData.EndDate != null) { EndDate.SendKeys(OrderLineData.EndDate.Value.ToString("M/d/yyyy")); } ProductInfoField.Click(); Wait.MLSeconds(200); Select.ByText(DeliveryPrefDD, OrderLineData.DeliveryPreferences); Wait.MLSeconds(100); ProductInfoField.Clear(); ProductInfoField.SendKeys(OrderLineData.ProductInformation); Wait.MLSeconds(100); if (OrderLineData.Impressions != null) { ImpressionsField.Clear(); ImpressionsField.SendKeys(OrderLineData.Impressions.ToString()); Wait.MLSeconds(100); } if (OrderLineData.Cost != null && OrderLineData.Cost != 0.0) { CostField.Clear(); CostField.SendKeys(OrderLineData.Cost.ToString()); Wait.MLSeconds(100); } else { Wait.MLSeconds(300); ProductInfoField.Click(); Wait.MLSeconds(200); } //if (OrderLineData.RateEnable) //{ // RateCheckBox.Click(); // Wait.MLSeconds(200); // RateField.Clear(); // RateField.SendKeys(OrderLineData.Rate.ToString()); //} //if (OrderLineData.GeoTargetEnable) //{ // GeoTaggingEnable.Click(); // Wait.MLSeconds(200); // GeoCountryParent.FindElement(By.LinkText("input")).SendKeys(OrderLineData.Countries); // GeoTargetStatesParent.FindElement(By.TagName("input")).SendKeys(OrderLineData.States); //} //if (!OrderLineData.KeyWordsEnable) //{ // KeyWordCheckBox.Click(); // Wait.MLSeconds(100); //} //if (!OrderLineData.CatogoriesEnable) //{ // IsCatagoryTargetCheckBox.Click(); // Wait.MLSeconds(100); //} //if (!OrderLineData.SubsitutionsAllow) //{ // Element.GetByValueFromList(AllowSubstitutionsRadios, "0").Click(); //} //if (!OrderLineData.DisplayMultipleAddsAllow) //{ // Element.GetByValueFromList(DisplayMultipleAdsRadios, "0").Click(); //} //if (!OrderLineData.SearchLeadingTextAllow) //{ // Element.GetByValueFromList(AllowSearchLeadingTextRadios, "0").Click(); //} //if (OrderLineData.Priority != null) //{ // Select.ByText(PerorityDD, OrderLineData.Priority.ToString()); //} //if (OrderLineData.ImpressionsPerDay != null) //{ // ImpressionsField.SendKeys(OrderLineData.ImpressionsPerDay.ToString()); //} //if (!string.IsNullOrEmpty(OrderLineData.AddGroupName)) //{ // Select.ByText(groupNameDD, OrderLineData.AddGroupName); //} //if (OrderLineData.ProductSelectionManual == false && OrderLineData.ProductSelectionManual != null) //{ // Element.GetByValueFromList(AutoProductSelectionRadio, "1").Click(); //} //else if (OrderLineData.ProductId_ManualSelection != null && OrderLineData.ProductId_ManualSelection.Count > 0) //{ // foreach (var item in OrderLineData.ProductId_ManualSelection) // { // AddProductToOrderLineByID(item); // } //} //if (OrderLineData.Status != null) //{ // Element.ScrolTo(StatusDD); // Select.ByText(StatusDD, OrderLineData.Status); // Wait.MLSeconds(100); //} return(this); }
public EditOrderLinePage FillOrderLine_Admin(OrderLineModel OrderLineData) { Wait.UntilDisply(PositionDD); if (!string.IsNullOrEmpty(OrderLineData.AddGroupName)) { Select.ByText(ProductGroupDD, "ESP Mobile"); Wait.MLSeconds(200); Select.ByText(AddTypeDD, "PFP"); Wait.MLSeconds(1000); } Select.ByText(ProductGroupDD, OrderLineData.ProductGroup); Wait.MLSeconds(200); Select.ByText(AddTypeDD, OrderLineData.AddType); Wait.MLSeconds(1000); if (OrderLineData.Position != null && OrderLineData.Position != 0) { Select.ByText(PositionDD, OrderLineData.Position.ToString()); Wait.MLSeconds(200); } if (OrderLineData.SearchTerm != null && OrderLineData.SearchTerm != "") { SelectSearchTerms(OrderLineData.SearchTerm); } if (OrderLineData.EndDate != null) { EndDate.SendKeys(OrderLineData.EndDate.Value.ToString("M/d/yyyy")); } ProductInfoField.Click(); Wait.MLSeconds(200); Select.ByText(DeliveryPrefDD, OrderLineData.DeliveryPreferences); Wait.MLSeconds(100); ProductInfoField.Clear(); ProductInfoField.SendKeys(OrderLineData.ProductInformation); Wait.MLSeconds(100); if (OrderLineData.Impressions != null) { ImpressionsField.Clear(); ImpressionsField.SendKeys(OrderLineData.Impressions.ToString()); Wait.MLSeconds(100); } if (OrderLineData.Cost != null && OrderLineData.Cost != 0.0) { CostField.Clear(); CostField.SendKeys(OrderLineData.Cost.ToString()); Wait.MLSeconds(100); } else { Wait.MLSeconds(500); try { ProductInfoField.Click(); } catch (Exception) { } Wait.MLSeconds(200); } if (OrderLineData.RateEnable) { RateCheckBox.Click(); Wait.MLSeconds(200); RateField.Clear(); RateField.SendKeys(OrderLineData.Rate.ToString()); } if (OrderLineData.GeoTargetEnable) { GeoTaggingEnable.Click(); Wait.MLSeconds(200); GeoCountryParent.FindElement(By.LinkText("input")).SendKeys(OrderLineData.Countries); GeoTargetStatesParent.FindElement(By.TagName("input")).SendKeys(OrderLineData.States); } if (!OrderLineData.KeyWordsEnable) { KeyWordCheckBox.Click(); Wait.MLSeconds(100); } if (!OrderLineData.CatogoriesEnable) { IsCatagoryTargetCheckBox.Click(); Wait.MLSeconds(100); } if (!OrderLineData.SubsitutionsAllow) { Element.GetByValueFromList(AllowSubstitutionsRadios, "0").Click(); } if (!OrderLineData.DisplayMultipleAddsAllow) { Element.GetByValueFromList(DisplayMultipleAdsRadios, "0").Click(); } if (!OrderLineData.SearchLeadingTextAllow) { Element.GetByValueFromList(AllowSearchLeadingTextRadios, "0").Click(); } if (OrderLineData.Priority != null) { Select.ByText(PerorityDD, OrderLineData.Priority.ToString()); } if (OrderLineData.ImpressionsPerDay != null) { ImpressionsField.SendKeys(OrderLineData.ImpressionsPerDay.ToString()); } if (!string.IsNullOrEmpty(OrderLineData.AddGroupName)) { try { Select.ByText(groupNameDD, OrderLineData.AddGroupName); } catch (Exception ex) { Logger.Log(LogingType.TextCaseFail, ex.ToString()); this.CloseBtn.Click(); Wait.MLSeconds(500); Modal.DirtyclickYes(); Wait.MLSeconds(100); throw new Exception(ex.Message); } } if (OrderLineData.ProductSelectionManual == false && OrderLineData.ProductSelectionManual != null) { Element.ScrolTo(StatusDD); Element.GetByValueFromList(AutoProductSelectionRadio, "1").Click(); Wait.AM_Loaging_ShowAndHide(); } else if (OrderLineData.ProductId_ManualSelection != null && OrderLineData.ProductId_ManualSelection.Count > 0) { foreach (var item in OrderLineData.ProductId_ManualSelection) { AddProductToOrderLineByID(item); } } if (OrderLineData.Status != null) { Element.ScrolTo(StatusDD); Select.ByText(StatusDD, OrderLineData.Status); Wait.MLSeconds(100); } return(this); }
public virtual ActionResult Submit() { string returnUrl; if (!_cartItemRepository.GetAll().Any()) { returnUrl = Url.Action(MVC.Home.Root()); return(RedirectedAsync(returnUrl, Resources.Error_CartIsEmpty, true)); } if (!CustomerContext.Current.IsAuthenticated) { returnUrl = Url.Action(MVC.Account.Login(Url.Action(MVC.Order.Submit()))); return(RedirectedAsync(returnUrl, Resources.Error_LoginRequired, true)); } var order = new OrderModel { AccessToken = SecurityHelpers.GenerateToken(8), Customer = CustomerContext.Current.Customer, SubmitDateUtc = DateTime.UtcNow, Status = OrderStatus.Submitted, IpAddress = Request.UserHostAddress }; _orderRepository.AddOrUpdate(order); _orderRepository.SaveChanges(); var cartItems = _cartItemRepository.GetAll(); var orderLines = new List <OrderLineModel>(); var products = _productRepository.GetAllByIds(cartItems.Select(cim => cim.Id).ToArray()); foreach (var cartItem in _cartItemRepository.GetAll()) { var product = products[cartItem.Id]; var orderLine = new OrderLineModel { Order = order, Product = product, Count = cartItem.Count }; _orderLineRepository.AddOrUpdate(orderLine); orderLines.Add(orderLine); order.TotalPrice += cartItem.TotalPrice; } _orderLineRepository.SaveChanges(); _orderRepository.SaveChanges(); _cartItemRepository.DeleteAll(); _cartItemRepository.SaveChanges(); _notificationController.OrderSubmitted(CustomerContext.Current.Customer, order, orderLines).Send(); returnUrl = Url.Action(MVC.Order.CheckOut(order.AccessToken)); return(RedirectedAsync(returnUrl, Resources.Success_OrderSubmitted)); }