Ejemplo n.º 1
0
 public void updateOrders(TaxiOrder orderToUpdate)
 {
     ordersInfo.UpdateOrder(orderToUpdate);
     currentDriver.PayCheck       += orderToUpdate.Cost;
     driverInfoCostDetails.Content = currentDriver.PayCheck + " грн";
     ShowOrdersInListView();
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> AgreeTaxiOrder(int?id, string receiverId, string receiverEmail)
        {
            if (id != null)
            {
                TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == id);

                if (taxiOrder != null)
                {
                    taxiOrder.OrderStatus   = "In progress";
                    taxiOrder.ReceiverId    = receiverId;
                    taxiOrder.ReceiverEmail = receiverEmail;
                    db.TaxiOrders.Update(taxiOrder);
                    await CreateNotification(taxiOrder);

                    //await SendEmail(taxiOrder.Id,true);
                    await db.SaveChangesAsync();

                    return(Json(taxiOrder, new JsonSerializerSettings
                                                 {
                                            ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                               
                    }));
                }
            }
            return(NotFound());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ConfirmTaxiOrder(int id, float duration, float distanse, float price)
        {
            List <TaxiOrder> taxi = await db.TaxiOrders.ToListAsync();

            if (id != null)
            {
                _logger.LogInformation("adssad" + id);
                TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == id);

                if (taxiOrder != null)
                {
                    taxiOrder.Distanse    = distanse;
                    taxiOrder.Duration    = duration;
                    taxiOrder.OrderStatus = "Done";
                    db.TaxiOrders.Update(taxiOrder);
                    await db.SaveChangesAsync();

                    price = price * distanse + duration * 10;
                    return(Json(price, new JsonSerializerSettings
                                                 {
                                            ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                               
                    }));
                }
            }
            return(Json(taxi, new JsonSerializerSettings
                                         {
                                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                       
            }));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> CreateTaxiOrder([FromBody] TaxiOrder taxiOrder)
        {
            // var user = await GetCurrentUserAsync();
            // var userId = user?.Id;
            // taxiOrder.OrderOwnerId = userId
            List <TaxiOrder> allOrders = await db.TaxiOrders.ToListAsync();

            if (taxiOrder.ReceiverId == null)
            {
                taxiOrder.OrderStatus = "Free";
                taxiOrder.Id          = allOrders[allOrders.Count - 1].Id + 1;
                db.TaxiOrders.Add(taxiOrder);
                await db.SaveChangesAsync();
            }
            else
            {
                taxiOrder.OrderStatus = "Free";
                taxiOrder.Id          = allOrders[allOrders.Count - 1].Id + 1;
                db.TaxiOrders.Add(taxiOrder);
                //await CreateNotification(taxiOrder);
                //await SendEmail(taxiOrder.Id,false);
                await db.SaveChangesAsync();
            }
            return(Json(taxiOrder, new JsonSerializerSettings
                                         {
                                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                       
            }));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> RemoveTaxiOrder(int index)
        {
            List <TaxiOrder> taxi = await db.TaxiOrders.ToListAsync();

            if (index != null)
            {
                TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == index);

                if (taxiOrder != null)
                {
                    db.TaxiOrders.Remove(taxiOrder);
                    await db.SaveChangesAsync();

                    taxi = await db.TaxiOrders.ToListAsync();

                    return(Json(taxi, new JsonSerializerSettings
                                                 {
                                            ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                               
                    }));
                }
            }
            return(Json(taxi, new JsonSerializerSettings
                                         {
                                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                       
            }));
        }
Ejemplo n.º 6
0
        public void Test_TaxiOrderPopertiesException()
        {
            TaxiOrder order = new TaxiOrder();

            order.Dispatch = "Виговського,123";
            //Destination equals to Dispatch
            order.Destination = "Виговського,123";
        }
Ejemplo n.º 7
0
 public void UpdateOrder(TaxiOrder orderToUpdate)
 {
     for (int i = 0; i < allOrders.Count; ++i)
     {
         if (allOrders[i].Id == orderToUpdate.Id)
         {
             allOrders[i] = orderToUpdate;
             break;
         }
     }
 }
        public OrderWindow(TaxiOrder _currentOrder)
        {
            InitializeComponent();
            currentOrder = _currentOrder;

            clientNameDesc.Content  = currentOrder.Client.Name;
            clientPhoneDesc.Content = currentOrder.Client.PhoneNumber;
            clientFromDesc.Content  = currentOrder.Dispatch;
            clientToDesc.Content    = currentOrder.Destination;
            clientTimeDesc.Content  = currentOrder.ArriveTime.ToString("dd-MM-yyyy HH:mm");
        }
Ejemplo n.º 9
0
        public void Test_TaxiOrderConstructorAndProperties()
        {
            TaxiClient client = new TaxiClient(2, "Модест", "+380966784576");
            TaxiDriver driver = new TaxiDriver(3, "Радомський", "Модест", 20, "BC1789AM", 5, 50, 189.75);
            TaxiOrder  order  = new TaxiOrder(1, client, driver, Convert.ToDateTime("2017-12-22 17:30"), "Шевченка,44", "Зелена,12", 123);

            Assert.AreEqual(order.Client.Id, client.Id);
            Assert.AreEqual(order.Driver.Id, driver.Id);
            Assert.AreEqual(order.ArriveTime, Convert.ToDateTime("2017-12-22 17:30"));
            Assert.AreEqual(order.Dispatch, "Шевченка,44");
            Assert.AreEqual(order.Destination, "Зелена,12");
            Assert.AreEqual(order.RoadTime, Convert.ToUInt32(123));
        }
Ejemplo n.º 10
0
        private static void Main()
        {
            var vwGolf = new CarModel(CarBrand.Volkswagen, "Golf", Weight.Kg(1200));

            var golfCar = new Car(
                model: vwGolf,
                color: "White",
                releaseYear: 2005,
                dateOfPurchase: new DateTime(2008, 02, 12));

            var taxiOrder = new TaxiOrder(golfCar, passangerCount: 2, driverShortName: "Frank M.");

            Console.ReadLine();
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> EditTaxiOrder([FromBody] TaxiOrder taxiOrderNew)
        {
            //TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == taxiOrderNew.Id);
            //taxiOrder = taxiOrderNew;
            _logger.LogInformation("ID this " + taxiOrderNew.Id);
            db.TaxiOrders.Update(taxiOrderNew);
            _logger.LogInformation(taxiOrderNew.StartPoint);
            await db.SaveChangesAsync();

            return(Json(taxiOrderNew.StartPoint, new JsonSerializerSettings
                                         {
                                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                       
            }));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> OrderById(int id)
        {
            if (id != null)
            {
                TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == id);

                if (taxiOrder != null)
                {
                    return(Json(taxiOrder, new JsonSerializerSettings
                                                 {
                                            ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                               
                    }));
                }
            }
            return(NotFound());
        }
Ejemplo n.º 13
0
        public async Task CreateNotification(TaxiOrder taxiOrder)
        {
            NotificationOrder notificationOrder = new NotificationOrder();

            notificationOrder.OrderOwnerId              = taxiOrder.OrderOwnerId;
            notificationOrder.OrderOwnerEmail           = taxiOrder.OrderOwnerEmail;
            notificationOrder.ReceiverId                = taxiOrder.ReceiverId;
            notificationOrder.ReceiverEmail             = taxiOrder.ReceiverEmail;
            notificationOrder.OrderId                   = taxiOrder.Id;
            notificationOrder.OrderStatus               = taxiOrder.OrderStatus;
            notificationOrder.NotificationStatusClient  = "Free";
            notificationOrder.NotificationStatusCarrier = "Free";
            notificationOrder.NotificationTitle         = "Заказ " + taxiOrder.StartPoint.Remove(0, taxiOrder.StartPoint.IndexOf('|') + 1) + " - "
                                                          + taxiOrder.EndPoint.Remove(0, taxiOrder.EndPoint.IndexOf('|') + 1) + " был принят. ";
            db.NotificationsOrder.Add(notificationOrder);
            await db.SaveChangesAsync();
        }
Ejemplo n.º 14
0
        public void updateOrders(TaxiOrder orderToUpdate)
        {
            using (UnitOfWork.UnitOfWork content = new UnitOfWork.UnitOfWork())
            {
                //UpdateOrderInfoINDB
                content.Orders.Update(orderToUpdate);
                content.Save();
                currentDriver.PayCheck       += orderToUpdate.Cost;
                driverInfoCostDetails.Content = currentDriver.PayCheck + " грн";

                //ShowOrdersInListView //Eager Loading
                var currentOrders = content.Orders.Get(s => s.Driver.DriverId == currentDriver.DriverId, includeProperties: "Client");
                orders.Items.Clear();
                foreach (var order in currentOrders)
                {
                    orders.Items.Add(order);
                }
            }
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> EditTaxiOrder(int?id)
        {
            if (id != null)
            {
                TaxiOrder taxiOrder = await db.TaxiOrders.FirstOrDefaultAsync(p => p.Id == id);

                taxiOrder.StartPoint = taxiOrder.StartPoint.Remove(0, taxiOrder.StartPoint.IndexOf('|') + 1);
                taxiOrder.EndPoint   = taxiOrder.EndPoint.Remove(0, taxiOrder.EndPoint.IndexOf('|') + 1);
                _logger.LogInformation("OKOKOKOKO");
                //db.TaxiOrders.Remove(taxiOrder);
                await db.SaveChangesAsync();

                if (taxiOrder != null)
                {
                    return(Json(taxiOrder, new JsonSerializerSettings
                                                 {
                                            ContractResolver = new CamelCasePropertyNamesContractResolver()
                                                                               
                    }));
                }
            }
            return(NotFound());
        }