Пример #1
0
        public UserModel Read(string e, string p)
        {
            // if (u == null)
            // {
            //   return null;
            // }
            // return _userList.Find(x => x.Email==u.Email && x.Password==u.Password);
            User u = _sa.GetUser(e, p);

            if (u == null)
            {
                return(null);
            }
            UserModel tempU = new UserModel();

            tempU.FirstName            = u.FirstName;
            tempU.LastName             = u.LastName;
            tempU.Address.Street       = u.Address.Street;
            tempU.Address.City         = u.Address.City;
            tempU.Address.AddressState = u.Address.AddressState;
            tempU.Address.ZipCode      = u.Address.ZipCode;
            tempU.Email    = u.UserAccount.Email;
            tempU.Password = u.UserAccount.Password;
            // tempU.UserType = u.UserType.UserType1;

            // get orders
            foreach (var o in u.Order)
            {
                Order      currentOrder = _sa.GetOrder(o.OrderId);
                OrderModel newOrder     = new OrderModel();
                newOrder.UserId    = currentOrder.UserId;
                newOrder.StoreId   = currentOrder.StoreId;
                newOrder.OrderDate = currentOrder.OrderDate;
                newOrder.TotalCost = currentOrder.OrderPizza.Count;
                foreach (var pizza in currentOrder.OrderPizza)
                {
                    Pizza      currentPizza = _sa.GetPizza(pizza.PizzaId);
                    PizzaModel newPizza     = new PizzaModel();
                    newPizza.Cost  = currentPizza.Cost;
                    newPizza.Crust = currentPizza.Crust.CrustName;
                    newPizza.Size  = currentPizza.Size.SizeName;
                    foreach (var topping in currentPizza.PizzaTopping)
                    {
                        Topping t = _sa.GetTopping(topping.ToppingId);
                        newPizza.Toppings.Add(t.ToppingName);
                    }
                    newOrder.Pizzas.Add(newPizza);
                }
                // newOrder.Store =
                tempU.Orders.Add(newOrder);

                // tempU.Orders.Add(newOrder);
            }
            // tempU.Orders = u.Order;
            return(tempU);
        }
Пример #2
0
        public StoreModel Read(string s)
        {
            // if (s == null)
            // {
            //   return null;
            // }
            Store      tempStore    = _sa.GetStore(s);
            StoreModel currentStore = new StoreModel();

            currentStore.StoreName            = tempStore.StoreName;
            currentStore.Address.Street       = tempStore.Address.Street;
            currentStore.Address.City         = tempStore.Address.City;
            currentStore.Address.AddressState = tempStore.Address.AddressState;
            currentStore.Address.ZipCode      = tempStore.Address.ZipCode;
            foreach (var o in tempStore.Order)
            {
                Order      currentOrder = _sa.GetOrder(o.OrderId);
                OrderModel newOrder     = new OrderModel();
                newOrder.UserId    = currentOrder.UserId;
                newOrder.StoreId   = currentOrder.StoreId;
                newOrder.OrderDate = currentOrder.OrderDate;
                newOrder.TotalCost = currentOrder.OrderPizza.Count;
                foreach (var pizza in currentOrder.OrderPizza)
                {
                    Pizza      currentPizza = _sa.GetPizza(pizza.PizzaId);
                    PizzaModel newPizza     = new PizzaModel();
                    newPizza.Cost  = currentPizza.Cost;
                    newPizza.Crust = currentPizza.Crust.CrustName;
                    newPizza.Size  = currentPizza.Size.SizeName;
                    foreach (var topping in currentPizza.PizzaTopping)
                    {
                        Topping t = _sa.GetTopping(topping.ToppingId);
                        newPizza.Toppings.Add(t.ToppingName);
                    }
                    newOrder.Pizzas.Add(newPizza);
                }
                // newOrder.Store =
                currentStore.Orders.Add(newOrder);

                // tempU.Orders.Add(newOrder);
            }

            // return _storeList.Find(x => x.Name == s.Name);
            return(currentStore);
        }