Example #1
0
        private void CreateTrackingOrder(Messages.Tracking.CreateTrackingOrderCommand cmd)
        {
            int userId = getUserIdFromJwt(cmd.JWT);

            if (userId == -1)
            {
                Sender.Tell(new Messages.Unauthorised());
            }

            using (MyContext context = MyContext.Connect(GetPath()))
            {
                TrackedOrder trackedOrder = new TrackedOrder()
                {
                    CreatedAt        = DateTime.Now,
                    CurrentLocation  = cmd.CurrentLocation,
                    EstimatedArrival = cmd.EstimatedArrival,
                    OrderId          = cmd.OrderId,
                    Progress         = 10, // processed
                    UserId           = userId
                };

                context.TrackedOrders.Add(trackedOrder);
                context.SaveChanges();

                Sender.Tell(new Messages.Tracking.TrackingOrderCreateSuccess());
            }
        }
Example #2
0
 private Messages.Tracking.TrackingOrder TrackingOrderDbToTrackingOrderMessage(TrackedOrder trackedOrder)
 {
     return(new Messages.Tracking.TrackingOrder
     {
         CreatedAt = trackedOrder.CreatedAt,
         CurrentLocation = trackedOrder.CurrentLocation,
         EstimatedArrival = trackedOrder.EstimatedArrival,
         Id = trackedOrder.Id,
         OrderId = trackedOrder.OrderId,
         Progress = trackedOrder.Progress,
         UserId = trackedOrder.UserId
     });
 }