public HttpResponseMessage AddOrder([FromBody] OrderReceivedModel data)
        {
            string             user = User.Identity.GetUserId();
            List <OrderDetail> res  = (List <OrderDetail>)JsonConvert.DeserializeObject(data.arrayMenu, typeof(List <OrderDetail>));

            return(orderManager.AddOrder(res, data.ID, data.IDShip, user, data.SDT, data.Latitude, data.Longtitude));
        }
Example #2
0
        public async Task SetUpProperties(int anOrderId)
        {
            OrderHead = await OrderHeadDataAccess.GetOrderHeadById(anOrderId);

            Containers    = (await ContainerTypeDataAccess.GetAllContainerTypes()).ToList();
            OrderReceived = new OrderReceivedModel()
            {
                ReceivedNum = await OrderReceivedDataAccess.GetNextReceivedNumberForOrderId(anOrderId)
            };
        }
Example #3
0
 public static OrderReceived ToEntity(this OrderReceivedModel anOrderReceivedModel)
 {
     return(new OrderReceived()
     {
         OrderId = anOrderReceivedModel.OrderId,
         ReceivedNum = anOrderReceivedModel.ReceivedNum,
         ReceivedContainerId = anOrderReceivedModel.ReceivedContainerId,
         ReceivedContainerQty = anOrderReceivedModel.ReceivedContainerQty,
         ReceivedDate = anOrderReceivedModel.ReceivedDate,
         ReceivedTime = TimeSpan.Parse(anOrderReceivedModel.ReceivedTimeString) //Timespans can not be passed using json, so the time must be passed in as a string and then converted into a TimeSpan
     });
 }
Example #4
0
        public async Task <ActionResult <OrderReceivedModel> > CreateOrderReceived(OrderReceivedModel anOrderReceivedModel)
        {
            try
            {
                var data = await OrderReceivedService.CreateOrderReceived(anOrderReceivedModel);

                return(Ok(JsonSerializer.Serialize(data)));
            }
            catch (Exception ex)
            {
                _logger.LogError("OrderReceivedController.CreateOrderReceived(int anOrderId) Not able to create order received {anOrderReceived}. | Message: {exMessage} | StackTrace: {stackTrace}", anOrderReceivedModel, ex.Message, ex.StackTrace);
                return(BadRequest(ex.Message));
            }
        }
        public void Produce()
        {
            var orderLog = _orderLogRepository.ReadOrderLog();
            var customer = _customerConsumer.Consume();

            var orderReceivedModel = new OrderReceivedModel
            {
                Customer = JsonSerializer.Deserialize <Customer>(customer),
                Order    = JsonSerializer.Deserialize <Order>(orderLog.Event)
            };
            var producer = new Producer <string, string>("OrderReceivedEvent", 0, "localhost:9092");

            producer.Produce($"Order{orderReceivedModel.Order.Id}Customer{orderReceivedModel.Customer.Id}", JsonSerializer.Serialize(orderReceivedModel));
        }
        public async Task <OrderReceivedModel> CreateOrderReceived(OrderReceivedModel anOrderReceivedModel)
        {
            var entity            = anOrderReceivedModel.ToEntity();
            var previousReceiveds = await Context.OrderReceived.Where(i => i.OrderId == anOrderReceivedModel.OrderId).ToListAsync();

            if (previousReceiveds == null || !previousReceiveds.Any())
            {
                entity.ReceivedNum = 1;
            }
            else
            {
                entity.ReceivedNum = (short)(previousReceiveds.Max(i => i.ReceivedNum) + 1);
            }

            Context.OrderReceived.Add(entity);
            await Context.SaveChangesAsync();

            return(entity.ToModel());
        }
 public async Task <OrderReceivedModel> CreateOrderReceived(OrderReceivedModel anOrderReceivedModel)
 {
     return(await DataAccessGeneric.HttpPostRequest <OrderReceivedModel>(Config["APIAddress"] + "api/OrderReceived/CreateOrderReceived", anOrderReceivedModel, _httpContextAccessor.HttpContext));
 }