public void Delete() { List<OrderItemModel> orderItems = OrderItemManager.GetOrderItems(); OrderItemModel orderItem = orderItems.FirstOrDefault(u => u.Price == 321); bool result = OrderItemManager.Delete(orderItem.OrderItemID); Assert.IsTrue(result); }
/// <summary> /// 更新信息 /// </summary> public int UpdateInfo(SqlTransaction trans, OrderItemModel ordItemModel, long SN) { string key = "Cache_OrderItem_Model_" + SN; CacheHelper.RemoveCache(key); return(ordItemDAL.UpdateInfo(trans, ordItemModel, SN)); }
public OrderItem CreateOrderItem(string userId, OrderItemModel item) { if (_orderRepo.FindById(item.OrderId)?.State == (int)OrderStatus.New) { var newOrderItem = _orderItemRepo.Create(new OrderItem() { Name = item.Name, Price = item.Price, ProductId = item.ProductId, Remark = item.Remark, CreatedAt = DateTime.UtcNow, CreatedBy = userId, OrderId = item.OrderId, OrderItemOptions = item.Options.Select(x => new OrderItemOption() { Name = x.Name, Value = x.Value }).ToList() }); return(newOrderItem); } else { throw new Exception($"Failed to create orderItem for order: {item.OrderId}"); } }
public async Task PrepareModelAsync(OrderModel model, Order order) { if (order == null) { throw new ArgumentNullException(nameof(order)); } model.Order = order; model.AddressesWithTypes.Add((order.BillingAddress, AddressType.Billing)); model.AddressesWithTypes.Add((order.DeliveryAddress, AddressType.Delivery)); model.UsersWithRoles.Add((order.Seller, RoleNames.Seller)); model.UsersWithRoles.Add((order.Customer, RoleNames.Customer)); foreach (var status in EnumHelper.GetEnumValues <OrderStatus>()) { var canChangeStatus = (await _orderService.CanChangeStatusAsync(order, status)).Success; model.StatusActions.Add((canChangeStatus, status)); } foreach (var orderItem in order.OrderItems) { var orderItemModel = new OrderItemModel(); await PrepareModelAsync(orderItemModel, orderItem); model.OrderItemModels.Add(orderItemModel); } }
public async Task PrepareModelAsync(OrderItemListModel model, IPageable <OrderItem> orderItems) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (orderItems == null) { throw new ArgumentNullException(nameof(orderItems)); } foreach (var orderItem in orderItems) { var orderItemModel = new OrderItemModel(); await PrepareModelAsync(orderItemModel, orderItem); model.Items.Add(orderItemModel); } model.Page = orderItems.Page; model.PageSize = orderItems.PageSize; model.PageFrom = orderItems.PageFrom; model.PageTo = orderItems.PageTo; model.TotalPages = orderItems.TotalPages; model.TotalItems = orderItems.TotalItems; }
IEnumerable <OrderItemModel> IOrderItemSearcher.Search(string query) { var res = new List <OrderItemModel>(); var searcher = ExamineManager.Instance.SearchProviderCollection["ChalmersILLOrderItemsSearcher"]; var searchCriteria = searcher.CreateSearchCriteria(Examine.SearchCriteria.BooleanOperation.Or); var results = searcher.Search(searchCriteria.RawQuery(query)); foreach (var item in results) { var newOrderItem = new OrderItemModel(); newOrderItem.NodeId = item.Id; newOrderItem.DueDate = item.Fields.GetValueString("DueDate") == "" ? DateTime.Now : DateTime.ParseExact(item.Fields.GetValueString("DueDate"), "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.None); newOrderItem.DeliveryDate = item.Fields.GetValueString("DeliveryDate") == "" ? DateTime.Now : DateTime.ParseExact(item.Fields.GetValueString("DeliveryDate"), "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.None); newOrderItem.Status = item.Fields.GetValueString("Status"); newOrderItem.OrderId = item.Fields.GetValueString("OrderId"); newOrderItem.PatronName = item.Fields.GetValueString("PatronName"); newOrderItem.PatronEmail = item.Fields.GetValueString("PatronEmail"); newOrderItem.ProviderOrderId = item.Fields.GetValueString("ProviderOrderId"); newOrderItem.FollowUpDate = item.Fields.GetValueString("FollowUpDate") == "" ? DateTime.Now : DateTime.ParseExact(item.Fields.GetValueString("FollowUpDate"), "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.None); newOrderItem.DeliveryLibrary = item.Fields.GetValueString("DeliveryLibrary"); newOrderItem.Type = item.Fields.GetValueString("Type"); newOrderItem.Reference = item.Fields.GetValueString("Reference"); newOrderItem.CreateDate = item.Fields["createDate"] == "" ? DateTime.Now : DateTime.ParseExact(item.Fields.GetValueString("createDate"), "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture, DateTimeStyles.None); newOrderItem.Log = item.Fields.GetValueString("Log"); res.Add(newOrderItem); } return(res); }
public static AuthOrSaleRequestModel GetDummyAuthRequestModel() { var card = new CreditCardModel(); var transaction = new TransactionModel(); var customer = new CustomerInfoModel { BillingAddress = new BillingAddressModel(), ShippingAddress = new ShippingAddressModel() }; var orderItem1 = new OrderItemModel(); var orderItem2 = new OrderItemModel(); var orderItems = new[] { orderItem1, orderItem2 }; var order = new OrderModel { OrderItems = orderItems }; var request = new AuthOrSaleRequestModel { CreditCard = card, CustomerInfo = customer, Transaction = transaction, Order = order }; return(request); }
private void PopulateDummyData() { OrderModel model = new Application.OrderModel(); model.Id = 1; model.Name = "Ben"; OrderItemModel itemModel = new Application.OrderItemModel(1, 1, 4, "Sandwich", 0, 0, State.None); OrderItemComponentModel itemComponent = new OrderItemComponentModel(1, "Brie", "Brie", 1, 1, 1, 1); itemModel.AddComponentModel(itemComponent); itemComponent = new OrderItemComponentModel(2, "Something", "Something", 1, 2, 1, 2); itemModel.AddComponentModel(itemComponent); model.AddOrderItemModel(itemModel); itemModel = new Application.OrderItemModel(2, 1, 5, "Coffee - Americano", 0, 0, State.None); model.AddOrderItemModel(itemModel); itemModel = new Application.OrderItemModel(3, 1, 6, "Coffee - Flat White", 0, 0, State.None); model.AddOrderItemModel(itemModel); ((AllItemsLayout)currentLayout).AddOrder(model); svc.SaveOrder(model); }
public IActionResult AddOrderItemInCart([FromBody] OrderItemModel orderItem) { if (orderItem == null || !ModelState.IsValid) { return(BadRequest(ModelState)); } var orderItemDataTransferObject = _shopCart.AddOrderItemInCart(new OrderItemDataTransferObject { ItemID = orderItem.Item.Id, ItemsCount = orderItem.ItemsCount }); return(CreatedAtRoute("GetShopCartItem", new { id = _shopCart.ShopCart.Count - 1 }, new OrderItemModel { Item = new ItemGetModel { Id = orderItemDataTransferObject.Item.Id, Name = orderItemDataTransferObject.Item.Name, Code = orderItemDataTransferObject.Item.Code, Price = orderItemDataTransferObject.Item.Price, Category = orderItemDataTransferObject.Item.Category }, ItemPrice = orderItemDataTransferObject.ItemPrice, ItemsCount = orderItemDataTransferObject.ItemsCount })); }
public void UpdateView(OrderItemModel model) { RemoveAllViews(); this.model = model; DisplayOrderItem(this.Context); }
public HttpResponseMessage Post() { string msg = ""; OrderItemModel parameters = new OrderItemModel(); try { var httpContext = (HttpContextBase)Request.Properties["MS_HttpContext"]; parameters = AjaxModel.GetParameters(httpContext); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, msg, Configuration.Formatters.JsonFormatter)); }; var user = mng.Orders.CreateOrder(parameters, out msg); if (user == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, msg, Configuration.Formatters.JsonFormatter)); } else { return(Request.CreateResponse(HttpStatusCode.OK, msg, Configuration.Formatters.JsonFormatter)); } //return Request.CreateResponse(HttpStatusCode.OK); }
public static OrderModel CreateOrder() { var orderItem1 = new OrderItemModel { Id = "Item1", Name = "ItemName1", Description = "Item Description 1", Quantity = "1", Price = 2, Taxable = false }; var orderItem2 = new OrderItemModel { Id = "Item2", Name = "ItemName2", Description = "Item Description 2", Quantity = "1", Price = 1, Taxable = false }; var orderItems = new[] { orderItem1, orderItem2 }; var order = new OrderModel { InvoiceNumber = DateTime.Now.Ticks.ToString(), Description = "Test Order", TotalAmount = 4.25M, Currency = "USD", OrderItems = orderItems }; return(order); }
public static OrderModel ToOrderModel(this Domain.Aggregates.Orders.Order order) { var model = new OrderModel() { OrderNumber = order.Id, Name = order.Name, Date = order.OrderDate, Status = order.OrderStatus.Name, Total = order.GetTotal(), City = order.Address.City, Country = order.Address.Country, Street = order.Address.Street, ZipCode = order.Address.ZipCode }; foreach (var o in order.OrderItems) { var orderitem = new OrderItemModel { ProductName = o.GetItemProductName(), Units = o.GetUnits(), UnitPrice = o.GetUnitPrice(), }; model.Total += o.GetUnits() * o.GetUnitPrice(); model.OrderItems.Add(orderitem); } return(model); }
public void ReportNewOrderItemUpdate(OrderItemModel orderItem) { // get the NotificationHub var context = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>(); // Extract the real chillin order status id from the umbraco id. int chillinOrderStatusId = 0; var ds = new Umbraco.Core.Services.DataTypeService(); PreValue iter; foreach (DictionaryEntry pv in _umbraco.GetPreValues(ConfigurationManager.AppSettings["umbracoOrderStatusDataTypeDefinitionName"])) { iter = ((PreValue)pv.Value); if (iter.Id == orderItem.StatusId) { chillinOrderStatusId = Convert.ToInt32(iter.Value.Split(':').First()); break; } } // create a notication object to send to the clients var n = new OrderItemNotification { NodeId = orderItem.NodeId, EditedBy = orderItem.EditedBy, EditedByMemberName = orderItem.EditedByMemberName, SignificantUpdate = true, IsPending = chillinOrderStatusId == 1 || chillinOrderStatusId == 2 || chillinOrderStatusId == 9 || (chillinOrderStatusId > 2 && chillinOrderStatusId <5 && DateTime.Now> orderItem.FollowUpDate), UpdateFromMail = false }; // this calls the javascript method updateStream(message) in all connected browsers context.Clients.All.updateStream(n); }
private void EditImage_Click(object sender, EventArgs e) { if (tillPopup != null) { return; } ImageViewWithId image = (ImageViewWithId)sender; if (container.Parent.Parent is CurrentOrderLayout) { CurrentOrderLayout layout = (CurrentOrderLayout)container.Parent.Parent; VariationsFragment variations = (VariationsFragment)layout.LeftFragment; editingPosition = image.Position; nameViews[editingPosition].SetTextColor(Color.DarkGreen); OrderItemModel thisModel = currentOrder.OrderItems[editingPosition]; svc.LockOrderItem(thisModel.Id); lockedOrderItemId = thisModel.Id; variations.RehydrateOrderItem(thisModel); } }
public HttpResponseMessage CreateOrderItem(OrderItemModel orderItemModel) { ResponseWithData <OrderItem> _response = new ResponseWithData <OrderItem>(); var model = Mapper.Map <OrderItemModel, OrderItem>(orderItemModel); model.CreatedDate = DateTime.Now; model.Status = 1; model.IsDeleted = false; var Result = _orderItemRepository.SaveReturnModel(model); if (Result != null) { _response.Type = "success"; _response.Message = "Order Item created successfully"; _response.data = Result; return(Request.CreateResponse(HttpStatusCode.OK, _response)); } else { _response.Type = "error"; _response.Message = "Something went wrong"; _response.data = null; return(Request.CreateResponse(HttpStatusCode.OK, _response)); } }
public ActionResult Create(OrderItemModel orderItem, int?garbage) { orderItem.Products = Repo.GetProducts(); try { // TODO: Add insert logic here if (ModelState.IsValid) { //Lib.OrderItem temp = new Lib.OrderItem //{ // BatchId = orderItem.BatchId, // ProductId = orderItem.ProductId, // Name = orderItem.Products.Where(p => p.Id == orderItem.ProductId).First().Name, // Quantity = orderItem.Quantity, // Cost = orderItem.Products.Where(p => p.Id == orderItem.ProductId).First().Cost * orderItem.Quantity //}; TempData["ItemBatch"] = orderItem.BatchId; TempData["ItemProduct"] = orderItem.ProductId; TempData["ItemName"] = orderItem.Products.Where(p => p.Id == orderItem.ProductId).First().Name; TempData["ItemQuantity"] = orderItem.Quantity; TempData["ItemCost"] = orderItem.Products.Where(p => p.Id == orderItem.ProductId).First().Cost *orderItem.Quantity; TempData.Keep(); //Repo.AddOrder(temp); return(RedirectToAction("WorkingIndex", "Order", TempData)); } return(View(orderItem)); } catch { return(View(orderItem)); } }
private bool IsDeliveryLibrarySameAsHomeLibrary(OrderItemModel orderItem) { return(orderItem.SierraInfo.home_library == null || (orderItem.DeliveryLibrary == "Huvudbiblioteket" && orderItem.SierraInfo.home_library.Contains("hbib")) || (orderItem.DeliveryLibrary == "Lindholmenbiblioteket" && orderItem.SierraInfo.home_library.Contains("lbib")) || (orderItem.DeliveryLibrary == "Arkitekturbiblioteket" && orderItem.SierraInfo.home_library.Contains("abib"))); }
public async Task <IEnumerable <OrderItemModel> > InsertOrderListAsync(IEnumerable <OrderItemModel> orderItems) { var user = await userRepository.GetUser(); List <OrderItemModel> orderItemList = new List <OrderItemModel>(); foreach (var orderItem in orderItems) { var orderItemVar = new OrderItemModel { SyncId = orderItem.SyncId, RepoId = orderItem.RepoId, Amount = orderItem.Amount, OrderId = orderItem.OrderId, ProductId = orderItem.ProductId, Quantity = orderItem.Quantity, AddedDate = DateTime.Now, TenantId = user.TenantId, CreatorUserId = requestIdentityProvider.UserId, LastModifierUserId = requestIdentityProvider.UserId }; orderItemList.Add(orderItemVar); } var newOrderItemList = orderItemRepository.InsertOrderList(mapper.Map <IEnumerable <OrderItem> >(orderItemList)); await orderItemRepository.SaveChangesAsync(); return(orderItemList); }
public ActionResult CreateOrderItem([FromBody] OrderItemModel model) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); _service.CreateOrderItem(userId, model); return(Ok()); }
public void SetOrderItemStarted(int id) { if (currentOrder.OrderItems.Where(i => i.Id == id).Count() != 0) { OrderItemModel model = currentOrder.OrderItems.Where(i => i.Id == id).Single(); model.State = State.Started; Resources res = container.Context.Resources; ImageViewWithId editButton = editButtons.Where(b => b.Id == id).Single(); #pragma warning disable CS0618 // Type or member is obsolete editButton.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); #pragma warning restore CS0618 // Type or member is obsolete editButton.Click -= EditImage_Click; ImageViewWithPosition deleteButton = deleteButtons.Where(b => b.Id == id).Single(); #pragma warning disable CS0618 // Type or member is obsolete deleteButton.SetImageDrawable(res.GetDrawable(Resource.Drawable.Locked)); #pragma warning restore CS0618 // Type or member is obsolete deleteButton.Click -= DeleteImage_Click; } SaveOrderItemState(id, State.Started); }
private void btnUpdateProduct_Click(object sender, EventArgs e) { try { if (gridProducts.CurrentRow != null) { string productName = gridProducts.CurrentRow.Cells[0].Value.ToString(); int quantity = int.Parse(gridProducts.CurrentRow.Cells[2].Value.ToString()); var addProductForm = new AddProductForm(productName, quantity); if (addProductForm.ShowDialog() == DialogResult.OK) { OrderItemModel itemToDelete = order.Items.First(o => o.Name == gridProducts.CurrentRow.Cells[0].Value.ToString()); order.Items.Remove(itemToDelete); OrderControler.AddItemToOrder(order, addProductForm.SelectedOrderItem); DisplayOrderItems(); } } else { MetroFramework.MetroMessageBox.Show(this, "Nie zaznaczono żadnej pozycji!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MetroFramework.MetroMessageBox.Show(this, "Błąd edytowania produktu!" + Environment.NewLine + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void AddOrderItem(OrderItemModel model) { int state = (int)model.State; string line = "ADD_ORDER_ITEM," + model.Id.ToString() + "," + model.OrderId.ToString() + "," + model.VariationId.ToString() + "," + model.DisplayName + "," + model.InOutStatus.ToString() + "," + model.DiscountId.ToString() + "," + state.ToString(); SendRecord(line); }
public async Task <IActionResult> CreateOrUpdate([FromBody] OrderItemModel order) { //order.Price = _productService.Get(order.IdProductPiece).Price; var result = await _Service.CreateOrUpdate(order); return(Ok(result)); }
private object GetPropertyByName(OrderItemModel record, string property) { return(property switch { "item_price" => record.Item_Price, "items_count" => record.Items_Count, _ => record.Id, });
public ActionResult DeleteConfirmed(int id) { OrderItemModel orderItemModel = db.OrderItemModels.Find(id); db.OrderItemModels.Remove(orderItemModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <int> DeleteOrderItemAsync(OrderItemModel model) { var orderItem = new OrderItem { OrderID = model.OrderID, OrderLine = model.OrderLine }; return(await DataService.DeleteOrderItemsAsync(orderItem)); }
public JsonResult UpdateOrderItem(OrderItemModel orderItem) { if (!this.permissionService.Authorize(StandardPermissionProvider.UpdateStoreSalesRecord)) { return(AccessDeniedJson()); } return(Json(orderItem)); }
private static void MapOrder(Order src, OrderItemModel oi) { var item = src.OrderItems.Single(x => x.OrderItemId == oi.OrderItemId); item.ProductId = oi.ProductId; item.OrderItemId = oi.OrderItemId; item.OrderId = src.OrderId; item.SalesTax = oi.SalesTax; }
public void Modified(OrderItemModel item) { var indexResponse = _elasticClient.Index(item, x => x.Id(item.NodeId)); if (indexResponse.ApiCall == null || !indexResponse.ApiCall.Success) { throw new OrderItemSearchIndexingException("Failed to index modified order item. Reason: " + indexResponse.DebugInformation + "; Data:" + JsonConvert.SerializeObject(item)); } }
public OrderItem Parse(OrderItemModel model) { try { var entry = new OrderItem(); //full object parsing if (!string.IsNullOrWhiteSpace(model.OrderUrl)) { if (model.ItemID != default(int)) { entry.ItemID = model.ItemID; } var uri = new Uri(model.OrderUrl); var orderId = int.Parse(uri.Segments.Last()); var order = _repo.GetOrder(model.ClientID, orderId); var product = _repo.GetProduct(entry.ItemID); entry.OrderID = orderId; entry.Order = order; entry.Product = product; } //partial parsing if (model.Quantity != default(int)) { entry.Quantity = model.Quantity; } return entry; } catch { return null; } }