public void ChangeStatusForOrder(int id, OrderStatusDto statusDto) { var order = _context.Orders .Include(x => x.OrderAmountProducts) .Include(x => x.Products) .FirstOrDefault(x => x.Id == id); if (order == null) { throw new EmptyListException($"Zamówienie o id:{id} nie istnieje"); } if (order.OrderStatusId == 5) { throw new BadRequestException("Nie można zmienić statusu zamówienia"); } if (statusDto.StatusId == 5) { foreach (var item in order.Products) { item.Amount += order.OrderAmountProducts.FirstOrDefault(x => x.ProductId == item.Id).Amount; } } order.OrderStatusId = statusDto.StatusId; _context.SaveChanges(); }
public override global::System.Data.DataSet Clone() { OrderStatusDto cln = ((OrderStatusDto)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public async Task <IHttpActionResult> SetOrderStatus(Guid id, OrderStatusDto dto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _orderService.SetOrderStatus(id, dto); return(Ok(result)); }
public async Task PostOrderStatus_ValidOrderDto_ShouldReturnOkResult() { OrderStatusDto orderDto = An.OrderStatusDto.WithName("status1").WithId(1); var resultFromController = await _orderStatusController.PostOrderStatus(orderDto); var okResult = resultFromController as OkResult; //Assert okResult.Should().NotBeNull(); okResult.StatusCode.Should().Be(StatusCodes.Status200OK); }
/// <summary> /// Binds the root. /// </summary> private void BindRoot() { List <JsonTreeNode> nodes = new List <JsonTreeNode>(); nodes.Add(JsonTreeNode.CreateNode("OrderSearch", String.Empty, "Order Search", ModuleName, "OrderSearch-List", String.Empty, TreeListType.OrderSearch.ToString(), true)); // PurchaseOrders node JsonTreeNode poNode = JsonTreeNode.CreateNode("PurchaseOrders", String.Empty, "Purchase Orders", ModuleName, "Orders-List", String.Empty, TreeListType.PurchaseOrders.ToString()); poNode.icon = Mediachase.Commerce.Shared.CommerceHelper.GetAbsolutePath("~/Apps/Order/images/PurchaseOrders.png"); poNode.children = new List <JsonTreeNode>(); poNode.children.Add(JsonTreeNode.CreateNode("PO-TodayOrders", "Today", ModuleName, "Orders-List", "filter=today&class=PurchaseOrder", true)); poNode.children.Add(JsonTreeNode.CreateNode("PO-WeekOrders", "This Week", ModuleName, "Orders-List", "filter=thisweek&class=PurchaseOrder", true)); poNode.children.Add(JsonTreeNode.CreateNode("PO-MonthOrders", "This Month", ModuleName, "Orders-List", "filter=thismonth&class=PurchaseOrder", true)); poNode.children.Add(JsonTreeNode.CreateNode("PO-AllOrders", "All", ModuleName, "Orders-List", "filter=all&class=PurchaseOrder", true)); nodes.Add(poNode); // PurchaseOrdersByStatus node JsonTreeNode posNode = JsonTreeNode.CreateNode("PurchaseOrdersByStatus", String.Empty, "Purchase Orders By Status", ModuleName, "Orders-List", String.Empty, TreeListType.PurchaseOrdersByStatus.ToString()); posNode.children = new List <JsonTreeNode>(); OrderStatusDto statusDto = OrderStatusManager.GetOrderStatus(); foreach (OrderStatusDto.OrderStatusRow statusRow in statusDto.OrderStatus.Rows) { posNode.children.Add(JsonTreeNode.CreateNode("PO-Status-" + statusRow.OrderStatusId, statusRow.Name, ModuleName, "Orders-List", String.Format("status={0}", statusRow.Name), true)); } nodes.Add(posNode); // Carts node JsonTreeNode cartsNode = JsonTreeNode.CreateNode("Carts", "Carts", ModuleName, "Orders-List", "filter=all&class=ShoppingCart", false); cartsNode.children = new List <JsonTreeNode>(); cartsNode.children.Add(JsonTreeNode.CreateNode("CART-TodayOrders", "Today", ModuleName, "Orders-List", "filter=today&class=ShoppingCart", true)); cartsNode.children.Add(JsonTreeNode.CreateNode("CART-WeekOrders", "This Week", ModuleName, "Orders-List", "filter=thisweek&class=ShoppingCart", true)); cartsNode.children.Add(JsonTreeNode.CreateNode("CART-MonthOrders", "This Month", ModuleName, "Orders-List", "filter=thismonth&class=ShoppingCart", true)); cartsNode.children.Add(JsonTreeNode.CreateNode("CART-AllOrders", "All", ModuleName, "Orders-List", "filter=all&class=ShoppingCart", true)); nodes.Add(cartsNode); // PaymentPlans node JsonTreeNode ppNode = JsonTreeNode.CreateNode("PaymentPlans", "Payment Plans (recurring)", ModuleName, "Orders-List", "filter=all&class=PaymentPlan", false); ppNode.children = new List <JsonTreeNode>(); ppNode.children.Add(JsonTreeNode.CreateNode("PP-TodayOrders", "Today", ModuleName, "Orders-List", "filter=today&class=PaymentPlan", true)); ppNode.children.Add(JsonTreeNode.CreateNode("PP-WeekOrders", "This Week", ModuleName, "Orders-List", "filter=thisweek&class=PaymentPlan", true)); ppNode.children.Add(JsonTreeNode.CreateNode("PP-MonthOrders", "This Month", ModuleName, "Orders-List", "filter=thismonth&class=PaymentPlan", true)); ppNode.children.Add(JsonTreeNode.CreateNode("PP-AllOrders", "All", ModuleName, "Orders-List", "filter=all&class=PaymentPlan", true)); nodes.Add(ppNode); WriteArray(nodes); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { OrderStatusDto ds = new OrderStatusDto(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public async Task <ActionResult <OrderStatusDto> > Add([FromBody] OrderStatusDto orderStatus) { try { var insertedOrderStatus = await orderStatusService.AddAsync(orderStatus); return(CreatedAtAction(nameof(Get), new { id = insertedOrderStatus.Id }, insertedOrderStatus)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
public async Task AddOrderStatusAsync(int orderId, IEnumerable <OrderStatusDto> orderStatusDtos) { foreach (var item in orderStatusDtos) { var status = new OrderStatusDto { OrderId = orderId, Time = item.Time, StatusId = item.StatusId }; await orderStatusService.AddAsync(status); } }
/// <summary> /// Binds the purchase orders by status. /// </summary> private void BindPurchaseOrdersByStatus() { List <JsonTreeNode> nodes = new List <JsonTreeNode>(); // PurchaseOrdersByStatus node OrderStatusDto statusDto = OrderStatusManager.GetOrderStatus(); foreach (OrderStatusDto.OrderStatusRow statusRow in statusDto.OrderStatus.Rows) { nodes.Add(JsonTreeNode.CreateNode("PO-Status-" + statusRow.OrderStatusId, statusRow.Name, ModuleName, "Orders-List", String.Format("status={0}", statusRow.Name), true)); } WriteArray(nodes); }
public async Task <IActionResult> ChangeOrderStatus(Guid id, [FromBody] OrderStatusDto orderStatus) { _logger.LogInformation("API - Order controller - ChangeOrderStatus"); var orderDb = await _ordersRepository.GetOrderByIdAsync(id); if (orderDb == null) { return(NotFound(new ProblemDetailsError(StatusCodes.Status404NotFound))); } _logger.LogInformation("Update order."); await _ordersRepository.UpdateOrderStatusAsync(id, orderStatus.Status); _logger.LogInformation("Return accepted"); return(Accepted()); }
public OrderStatusDto GetAllOrderStatusById(int id) { var context = new orderstatusEntities(); OrderStatusDto orderStatusDto = new OrderStatusDto(); try { var status = context.order_status_by_store.Where(x => x.id == id && x.is_valid == 1).SingleOrDefault(); if (status != null) { orderStatusDto = new OrderStatusDto { IsPublic = status.order_status_values.isPublic.ToString().Equals("1")?true:false, Text = status.order_status_values.text }; } } catch (InvalidOperationException exc) { log.Error("Error InvalidOperationException GetAllOrderStatusById: " + exc.Message); AccessConnectionHandler.log.Error(exc); } catch (ArgumentNullException exc) { log.Error("Error ArgumentNullException GetAllOrderStatusById: " + exc.Message); AccessConnectionHandler.log.Error(exc); } catch (NullReferenceException exc) { log.Error("Error NullReferenceException GetAllOrderStatusById: " + exc.Message); AccessConnectionHandler.log.Error(exc); } catch (OptimisticConcurrencyException exc) { log.Error("Error OptimisticConcurrencyException GetAllOrderStatusById: " + exc.Message); AccessConnectionHandler.log.Error(exc); } catch (UpdateException exc) { log.Error("Error: " + exc.Message + " locations" + exc.TargetSite); AccessConnectionHandler.log.Error(exc); } finally { context.Dispose(); } return(orderStatusDto); }
public async Task UpdateOrderStatus_ValidOrderIdAndValidOrderDtoStatus_ShouldReturnOkResult() { OrderStatusDto orderDto = An.OrderStatusDto.WithName("status1").WithId(1); OrderStatus order = An.OrderStatus.WithName("status2"); _unitOfWork.Setup(u => u.OrderStatuses.GetAsync(1)) .ReturnsAsync(order); var resultFromController = await _orderStatusController.UpdateOrderStatus(1, orderDto); var okResult = resultFromController as OkResult; //Assert okResult.Should().NotBeNull(); okResult.StatusCode.Should().Be(StatusCodes.Status200OK); }
public async Task <ActionResult <OrderStatusDto> > Update(int id, [FromBody] OrderStatusDto orderStatus) { if (id != orderStatus.Id) { return(BadRequest()); } try { var updatedOrderStatus = await orderStatusService.UpdateAsync(orderStatus); return(Ok(updatedOrderStatus)); } catch (Exception ex) { return(StatusCode(500, ex)); } }
/// <summary> /// Saves changes in OrderStatusDto. Not implemented! /// </summary> /// <param name="dto">The dto.</param> public static void SaveOrderStatus(OrderStatusDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("OrderStatusDto can not be null")); } // TODO: implement //// TODO: Check if user is allowed to perform this operation //DataCommand cmd = OrderDataHelper.CreateConfigDataCommand(); //using (TransactionScope scope = new TransactionScope()) //{ // DataHelper.SaveDataSetSimple(cmd, dto, "OrderStatus"); // scope.Complete(); //} }
/// <summary> /// Loads the data and data bind. /// </summary> private void LoadDataAndDataBind() { OrderStatusDto statusDto = OrderStatusManager.GetOrderStatus(); OrderStatus.DataValueField = "Name"; OrderStatus.DataSource = statusDto.OrderStatus; OrderStatus.DataBind(); OrderStatus.Items.Insert(0, new ListItem("any", "")); DataRange.Items.Clear(); DataRange.Items.Add(new ListItem(SharedStrings.All, "")); DataRange.Items.Add(new ListItem(SharedStrings.Today, "today")); DataRange.Items.Add(new ListItem(SharedStrings.This_Week, "thisweek")); DataRange.Items.Add(new ListItem(SharedStrings.This_Month, "thismonth")); StringBuilder script = new StringBuilder("this.disabled = true;\r\n"); script.AppendFormat("__doPostBack('{0}', '');", btnSearch.UniqueID); btnSearch.OnClientClick = script.ToString(); }
public async Task <IActionResult> PostOrderStatus(OrderStatusDto orderStatus) { if (orderStatus == null) { return(UnprocessableEntity(orderStatus)); } var orderStatusToSave = _mapper.Map <OrderStatusDto, OrderStatus>(orderStatus); try { await _unitOfWork.CompleteAsync(); } catch (DbUpdateConcurrencyException) { return(BadRequest()); } return(Ok()); }
public static OrderStatus Map(this OrderStatusDto orderStatusDto) { switch (orderStatusDto) { case OrderStatusDto.Created: return(OrderStatus.OrderCreated); case OrderStatusDto.Placed: return(OrderStatus.OrderPlaced); case OrderStatusDto.Dispatched: return(OrderStatus.OrderDispatched); case OrderStatusDto.Completed: return(OrderStatus.OrderCompleted); default: throw new NotImplementedException("Order Status Mapping not implemented DTO -> Model"); } }
public IActionResult getOrderStatus(string site, string po_number) { if (po_number == null || site == null) { return(BadRequest()); } var siteName = Startup.Configuration["SiteName"]; if (site != siteName) { return(NotFound()); } var orderStatus = new OrderStatusDto(); var thisOrder = _context.Orders.Where(o => o.PoNumber == po_number).FirstOrDefault(); if (thisOrder != null) { orderStatus.Status = _isettings.getOrderStatus(Convert.ToInt32(thisOrder.Status)); } return(Ok(orderStatus)); }
public async Task <IActionResult> UpdateOrderStatus(int id, [FromBody] OrderStatusDto orderStatus) { if (orderStatus == null) { return(UnprocessableEntity(orderStatus)); } if (id != orderStatus.Id) { return(UnprocessableEntity()); } var orderStatusInDb = await _unitOfWork.OrderStatuses.GetAsync(id); _mapper.Map(orderStatus, orderStatusInDb); try { await _unitOfWork.CompleteAsync(); } catch (DbUpdateConcurrencyException) { bool exists = await _unitOfWork.OrderStatuses.ExistsAsync(o => o.Id == id); if (!exists) { return(NotFound()); } else { throw; } } return(Ok()); }
public Task <int> orderStatusChange(Guid userId, Guid orderId, string nowStatus, OrderStatusDto OrderStatusDto) { return(Task <int> .Run(() => { var order = _context.orders.FirstOrDefault(o => o.Id == orderId); if (order == null) { return -6; } //無效訂單id if (!_context.users.Any(u => u.Id == userId)) { return -5; } //無效使用者id if (order.Lender != userId && order.p_ownerId != userId) { return -5; } OrderStatus preStatus = OrderStatus.NONE; OrderStatus nextStatus = OrderStatus.NONE; var statusArray = Enum.GetValues(typeof(OrderStatus)); foreach (OrderStatus status in statusArray) { if (status.getStatusDesc() == nowStatus) { preStatus = status; } } switch (preStatus) { case OrderStatus.CREATE: nextStatus = OrderStatus.SEND; break; case OrderStatus.SEND: nextStatus = OrderStatus.ARRIVED; break; case OrderStatus.ARRIVED: nextStatus = OrderStatus.SENDBACK; break; case OrderStatus.SENDBACK: nextStatus = OrderStatus.GETBACK; break; } Console.WriteLine( "Input Status = " + preStatus + "\nNext Status = " + nextStatus + "\nOrder Status = " + order.status ); if (preStatus == OrderStatus.NONE || nextStatus == OrderStatus.NONE || (int)preStatus >= (int)nextStatus) { return -4; } //狀態設定不正確 if (order.status != preStatus) { return -3; } //非目前狀態 bool errFlag = false; var newTime = DateTime.Now; switch (nextStatus) { case OrderStatus.PAYED: order.PayTime = newTime; if (order.Lender != userId) { errFlag = true; } break; case OrderStatus.SEND: order.ProductSend = newTime; if (order.p_ownerId != userId) { errFlag = true; } break; case OrderStatus.ARRIVED: order.ProductArrive = newTime; if (order.Lender != userId) { errFlag = true; } break; case OrderStatus.SENDBACK: order.ProductSendBack = newTime; if (order.Lender != userId) { errFlag = true; } break; case OrderStatus.GETBACK: order.ProductGetBack = newTime; if (order.p_ownerId != userId) { errFlag = true; } break; default: errFlag = true; break; } if (errFlag) { return -2; } //操作錯誤 order.status = nextStatus; if ((order.TradeMethod == 1 && nextStatus == OrderStatus.ARRIVED) || (order.TradeMethod != 1 && nextStatus == OrderStatus.GETBACK)) { order.status = OrderStatus.CLOSE; } OrderStatusDto.NewStatus = nextStatus.getStatusDesc(); OrderStatusDto.DateTime = newTime.ToString("yyyy-MM-dd\"T\"HH:mm", DateTimeFormatInfo.InvariantInfo); _context.orders.Update(order); save(); return _context.orders.Any(o => o == order) ? 0 : -1; })); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); OrderStatusDto ds = new OrderStatusDto(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "OrderStatusDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public ActionResult ChangeStatus([FromRoute] int id, [FromBody] OrderStatusDto dto) { _ordersSrevice.ChangeStatusForOrder(id, dto); return(NoContent()); }
public OrderStatusDto GetAllOrderStatusById(int id) { var context = new orderstatusEntities(); OrderStatusDto orderStatusDto = new OrderStatusDto(); try { var status = context.order_status_by_store.Where(x=> x.id == id && x.is_valid == 1).SingleOrDefault(); if (status != null) { orderStatusDto = new OrderStatusDto { IsPublic = status.order_status_values.isPublic.ToString().Equals("1")?true:false, Text = status.order_status_values.text }; } } catch (InvalidOperationException exc) { AccessConnectionHandler.log.Error(exc); } catch (ArgumentNullException exc) { AccessConnectionHandler.log.Error(exc); } catch (NullReferenceException exc) { AccessConnectionHandler.log.Error(exc); } catch (OptimisticConcurrencyException exc) { AccessConnectionHandler.log.Error(exc); } catch (UpdateException exc) { AccessConnectionHandler.log.Error(exc); } finally { context.Dispose(); } return orderStatusDto; }
public async void firebasePushNotifaction(Guid uid, Guid oid, OrderStatusDto oStatusDto) { var odr = _context.orders.FirstOrDefault(o => o.Id == oid); if (odr == null) { return; } Guid tmpUsrId = new Guid(); if (uid == odr.Lender) { tmpUsrId = odr.p_ownerId; } else if (uid == odr.p_ownerId) { tmpUsrId = (Guid)odr.Lender; } else { return; } //異常則不發送 var usr = _context.users.FirstOrDefault(u => u.Id == tmpUsrId); if (usr == null) { return; } var token = usr.dTK;//需編碼加密 取得後解開 Debug.WriteLine("token:" + token); if (token == null || token == "") { return; } // This registration token comes from the client FCM SDKs. var registrationToken = token; // See documentation on defining a message payload. var message = new Message { Data = new Dictionary <string, string>() { { "noteType", "status" }, { "ProductTitle", odr.p_Title }, { "OrderId", odr.Id.ToString() }, { "newStatus", oStatusDto.NewStatus }, { "newStatusTime", oStatusDto.DateTime } }, Token = registrationToken }; // Send a message to the device corresponding to the provided // registration token. try { string response = await FirebaseMessaging.DefaultInstance .SendAsync(message); // Response is a message ID string. Debug.WriteLine("Successfully sent message: " + response); } catch (Exception e) { Debug.WriteLine("Error meaasge: " + e.Message); } }