public static Data.Entities.Orders Map(Domain.Orders dmOrders)
        {
            Data.Entities.Orders deOrders = new Entities.Orders();

            deOrders.Id         = dmOrders.Id;
            deOrders.OrderCost  = dmOrders.OrderCost;
            deOrders.LocationId = dmOrders.LocationId;
            deOrders.UserId     = dmOrders.UserId;

            return(deOrders);
        }
Esempio n. 2
0
        //Done: Don't touhc for now
        public static bool SetupOrderInDBForUser() //return the orderid in the database
        {
            if (_CurrentUsersList[0].PizzaBoxStore.OrderHistory.Count > 0)
            {
                CheckIfUserCanOrder();
                return(false);
            }
            try
            {
                System.Console.WriteLine("\n\t\tCreating your order ...");
                var newOrderForDB = new PizzaBox.Data.Entities.Orders();
                //Transfering the store id that the user just selected in AuthenticateUsers.cs
                newOrderForDB.LocationId = _CurrentUsersList[0].PizzaBoxStore.PrimaryStoreID;
                newOrderForDB.UserId     = _CurrentUsersList[0].UserID;

                _CurrentUsersList[0].PizzaBoxStore.LastOrderTime = DateTime.Now;
                newOrderForDB.TimeStamp = _CurrentUsersList[0].PizzaBoxStore.LastOrderTime;

                //Add new order to the table
                _db.Orders.Add(newOrderForDB);
            }
            catch (System.Exception)
            {
                System.Console.WriteLine("Error with adding order to queue.");
                return(false);
            }

            try
            {
                _db.SaveChanges();
            }
            catch (System.Exception)
            {
                System.Console.WriteLine("Unable to connect to database due to network issue, or the order is missing some information.");
                return(false);
            }

            try
            {
                var orderIdInD = _db.Orders.First(o => (o.TimeStamp == _CurrentUsersList[0].PizzaBoxStore.LastOrderTime)).OrderId;
                _CurrentUsersList[0].PizzaBoxStore.CurrentOrder = new PizzaBox.Domain.Models.Order();
                _CurrentUsersList[0].PizzaBoxStore.CurrentOrder.SetOrderID(orderIdInD);
            }
            catch (System.Exception)
            {
                System.Console.WriteLine("Unable to reterive the order we just made.");
                return(false);
            }
            return(true);
        }