Beispiel #1
0
    public int Save()
    {
        int i = 0;

        if (!HaveImported)
        {
            int payStatus = 1;
            if (OrderType.Trim().Equals("现货未付"))
            {
                payStatus = 0;
            }
            string[,] insertParam = { { "flow_number",           "varchar",  flowNumber.Trim()                  },
                                      { "type",                  "varchar",  OrderType.Trim()                   },
                                      { "open_id",               "varchar",  ""                                 },
                                      { "member_name",           "varchar",  MemberName.Trim()                  },
                                      { "cell_number",           "varchar",  CellNumber.Trim()                  },
                                      { "price",                 "float",    OrderPrice.ToString()              },
                                      { "dragon_ball_used",      "int",      UsedDragonBallCount.ToString()     },
                                      { "ticket_used_amount",    "float",    UsedTicketAmount.ToString().Trim() },
                                      { "real_paid_summary",     "float",    RealPaidAmount.ToString()          },
                                      { "dragon_ball_rate",      "float",    DragonBallRate.ToString().Trim()   },
                                      { "dragon_ball_generated", "int",      GenerateDraonBallCount.ToString()  },
                                      { "pay_status",            "int",      payStatus.ToString()               },
                                      { "order_date",            "datetime", Date.ToShortDateString()           } };
            i = DBHelper.InsertData("orders", insertParam);
            if (i > 0)
            {
                foreach (OrderDetail dtl in orderDetails)
                {
                    dtl.Save();
                }
            }
        }
        return(i);
    }
        public void Add_Order(int id, string name, string type, int time, int hero_id, Zone[] zones)
        {
            order = new Order {
                Name = name, Type = type, Time = time
            };

            orderPrice = new OrderPrice {
                Id = order.Id, Price = 1000, Order = order
            };

            order.OrderPrice = orderPrice;

            hero = db.HeroEntities.Find(hero_id);

            order.Hero = hero;

            db.HeroEntities.Find(hero_id).Orders = new List <Order> {
                order
            };

            for (int i = 0; i < zones.Length; i++)
            {
                db.ZoneEntities.Find(zones[i].Id).Orders = new List <Order> {
                    order
                };
            }


            db.OrderEntities.Add(order);
            db.OrderPrices.Add(orderPrice);
            db.SaveChanges();
        }
Beispiel #3
0
 public override string ToString()
 {
     return("Order number: " + OrderNumber.ToString() + Environment.NewLine + "" +
            DatabaseMethods.SelectOffers().Where(x => x.OfferNumber == TravelOfferNumber).First().ToString() + Environment.NewLine +
            "Client: " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == OrderClientNumber).First().Name + " " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == OrderClientNumber).First().LastName + Environment.NewLine +
            "Worker: " + ServiceWorker.Name + " " + ServiceWorker.LastName + Environment.NewLine +
            "Order price: €" + OrderPrice.ToString() + Environment.NewLine +
            "Travelers amount: " + OrderClientsAmount.ToString() + Environment.NewLine +
            "Travel start date: " + TravelStartDate.ToShortDateString() + Environment.NewLine +
            "Order registered on: " + OrderRegisterDate.ToShortDateString());
 }
Beispiel #4
0
        /// <summary>
        /// Возвращает строку запроса типа ?min_lat=55.30077916694387&min_lng=36.974153699712836&max_lat=56.200586833056136&max_lng=38.26083830028717
        /// </summary>
        /// <returns></returns>
        public string ToUrlQuery()
        {
            var list = new List <string>(15);

            if (!string.IsNullOrWhiteSpace(Id))
            {
                list.Add($"id={Id}");
            }
            if (WeightGramms > 0)
            {
                list.Add($"weight={WeightGramms.ToString()}");
            }
            if (OrderPrice > 0)
            {
                list.Add($"order_price={OrderPrice.ToString()}");
            }
            if (!string.IsNullOrWhiteSpace(City))
            {
                list.Add($"city={City}");
            }
            if (!string.IsNullOrWhiteSpace(Region))
            {
                list.Add($"region={Region}");
            }
            if (!string.IsNullOrWhiteSpace(CountryCode))
            {
                list.Add($"country={CountryCode}");
            }
            if (!string.IsNullOrWhiteSpace(Type))
            {
                list.Add($"type={Type}");
            }
            if (!string.IsNullOrWhiteSpace(Partner))
            {
                list.Add($"partner={Partner}");
            }
            if (MinLng.HasValue && MaxLng.HasValue && MinLat.HasValue && MaxLat.HasValue)
            {
                list.Add($"min_lng={MinLng.ToString().Replace(",", ".")}");
                list.Add($"max_lng={MaxLng.ToString().Replace(",", ".")}");
                list.Add($"min_lat={MinLat.ToString().Replace(",", ".")}");
                list.Add($"max_lat={MaxLat.ToString().Replace(",", ".")}");
            }
            if (RegionCities.HasValue)
            {
                list.Add($"region_cities={(RegionCities.Value ? "Y" : "N")}");
            }
            if (!string.IsNullOrWhiteSpace(InSales))
            {
                list.Add($"insales={InSales}");
            }
            return("?" + string.Join("&", list));
        }
Beispiel #5
0
        // Genera la factura de la mesa 'tableID'
        private Bill generateBill(int tableID)
        {
            Bill bill = new Bill();

            bill.CompanyInfo    = SqlProcessor.selectRestaurant();
            bill.CompanyAddress = SqlProcessor.selectAddress(bill.CompanyInfo.NIF);
            Table table = SqlProcessor.selectTable(tableID);

            bill.ClientInfo    = SqlProcessor.selectClient(table.Client);
            bill.ClientAddress = SqlProcessor.selectAddress(bill.ClientInfo.Dni);
            bill.Date          = DateTime.Now;
            bill.TableID       = tableID;
            bill.Iva           = SqlProcessor.selectIVA();
            int dVisit = SqlProcessor.selectDiscountedVisit();

            if (bill.ClientInfo.Appearances % dVisit == 0 && bill.ClientInfo.Appearances > 0)   // descuento por fidelidad
            {
                bill.Discount = SqlProcessor.selectDiscount();
            }
            else
            {
                bill.Discount = 0.0;
            }
            bill.Id     = SqlProcessor.selectNBill();
            bill.Serial = SqlProcessor.selectSerial();
            bill.Paid   = 0;
            List <Order> orders = SqlProcessor.selectTableOrders(tableID, true);

            foreach (Order order in orders)
            {
                OrderPrice oPrice  = new OrderPrice();
                Product    product = SqlProcessor.selectProduct(order.Product);
                oPrice.Order = order;
                oPrice.Price = product.Price;
                if (product.DiscountedUnit > 0) // descuento por producto
                {
                    oPrice.Discount = ((int)(order.Amount / product.DiscountedUnit)) * product.Discount * product.Price;
                }
                else
                {
                    oPrice.Discount = 0;
                }
                oPrice.Total = (product.Price * order.Amount) - oPrice.Discount;
                bill.Orders.Add(oPrice);
                bill.Subtotal += oPrice.Total;
            }
            bill.TaxBase = bill.Subtotal - bill.Subtotal * (bill.Discount / 100);
            bill.Total   = bill.TaxBase + bill.TaxBase * (bill.Iva / 100);
            bill.Quote   = bill.Total - bill.TaxBase;
            return(bill);
        }
Beispiel #6
0
        public static void Main()
        {
            Console.WriteLine("Welcome to Pierre's Bakery!");
            Console.WriteLine("Bread is $5. OR buy 2, get 1 free.");
            Console.WriteLine("Pastry is $2. OR buy 3 for $5.");

            Console.WriteLine("How many loaves of Bread do you want? Enter a number please.");
            string stringBread = Console.ReadLine();
            int    BreadNumber = int.Parse(stringBread);

            Console.WriteLine("How many pastries do you want? Enter a number please.");
            string stringPastry = Console.ReadLine();
            int    PastryNumber = int.Parse(stringPastry);

            int breadResponse  = Bread.CalculateBread(5, BreadNumber);
            int pastryResponse = Pastry.CalculatePastry(2, PastryNumber);
            int overallOrder   = OrderPrice.OrderIs(breadResponse, pastryResponse);

            Console.WriteLine("Your order: " + BreadNumber + " loaves for $" + breadResponse + ".");
            Console.WriteLine("Your order: " + PastryNumber + " individual pastries for $" + pastryResponse + ".");
            Console.WriteLine("Your total will be $" + overallOrder + ".");
        }
Beispiel #7
0
        public List <PizzaDto> GetPizzaAtPriceOrderIds(int[] ids)
        {
            List <PizzaDto> pizzas = new List <PizzaDto>();

            ids.ToList().ForEach(id => {
                OrderPrice orderPrice = _orderPriceRepository.GetItem(id);
                Price price           = _priceRepository.GetItem(orderPrice.PriceId);
                Pizza pizza           = _pizzaRepository.GetItem(price.PizzaId);
                PizzaDto foundPizza   = pizzas.Find(value => value.Id == pizza.Id);
                if (foundPizza != null)
                {
                    PriceDto priceDto = ConverPrice(price);
                    priceDto.Count    = orderPrice.Count;
                    foundPizza.Prices.Add(priceDto);
                }
                else
                {
                    PizzaDto pizzaDto             = ConvertPizza(pizza);
                    pizzaDto.Prices.First().Count = orderPrice.Count;
                    pizzas.Add(pizzaDto);
                }
            });
            return(pizzas);
        }
Beispiel #8
0
 public OrderPrice GetOrderPrice(string orderId)
 {
     try
     {
         OrderPrice result = new OrderPrice();
         StringBuilder strSql = new StringBuilder();
         strSql.AppendFormat(@"Select O.SSMoney,O.MileageMoney,O.WaitMoney,O.WaitTime,O.State,D.Mileage
               from  D_OrderInfo(nolock) O join D_OrderDetail(nolock)D on O.OrderId=D.OrderId where O.OrderId='{0}'", orderId);
         var dt = helper.GetDataTable(strSql.ToString());
         if (dt != null && dt.Rows.Count > 0)
         {
             result.SSMoney = dt.Rows[0]["SSMoney"] == DBNull.Value ? 0 :Convert.ToDouble(dt.Rows[0]["SSMoney"]);
             result.MileageMoney = dt.Rows[0]["MileageMoney"] == DBNull.Value ? 0 : Convert.ToDouble(dt.Rows[0]["MileageMoney"]);
             result.WaitMoney = dt.Rows[0]["WaitMoney"] == DBNull.Value ? 0 : Convert.ToDouble(dt.Rows[0]["WaitMoney"]);
             result.WaitTime = dt.Rows[0]["WaitTime"] == DBNull.Value ? 0 : Convert.ToDouble(dt.Rows[0]["WaitTime"]);
             result.State = dt.Rows[0]["State"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[0]["State"]);
             result.Mileage = dt.Rows[0]["Mileage"] == DBNull.Value ? 0 : Convert.ToDouble(dt.Rows[0]["Mileage"]);
         }
         return result;
     }
     catch (Exception ex)
     {
         LogControl.WriteError(string.Format("{0}|GetOrderPrice获取失败|Error:{1}", DateTime.Now, ex.Message));
         return null;
     }
 }
 public void OrderIs_TwoPlusFiveisSeven_True()
 {
     Assert.AreEqual(7, OrderPrice.OrderIs(2, 5));
 }
Beispiel #10
0
        public OrderDto SaveOrder(OrderDto newOrder)
        {
            Order order = _orderRepository.GetItem(newOrder.Id) ?? new Order {
            };

            order.Name    = newOrder.Name;
            order.Surname = newOrder.Surname;
            order.Phone   = newOrder.Phone;
            order.Total   = newOrder.Total;
            if (newOrder.AccountId == 0 || newOrder.AccountId == null)
            {
                order.AccountId = null;
            }
            else
            {
                order.AccountId = newOrder.AccountId;
            }
            order.Address = newOrder.Address;
            if (order.Id == 0)
            {
                order.CreatedAt = DateTime.Now;
            }
            order = _orderRepository.Save(order);
            if (order.OrderPrices != null)
            {
                order.OrderPrices.ToList().ForEach(price =>
                {
                    PizzaPriceDto foundPrice = null;
                    newOrder.Pizzas.ForEach(pizza =>
                    {
                        foundPrice = pizza.Prices.Find(newPrice =>
                        {
                            return(newPrice.Id == price.PriceId);
                        });
                    });
                    if (foundPrice == null)
                    {
                        _orderPriceRepository.Delete(price.Id);
                    }
                });
            }
            newOrder.Pizzas.ForEach(pizza =>
            {
                pizza.Prices.ForEach(price =>
                {
                    OrderPrice foundOrderPrice = null;
                    if (order.OrderPrices != null)
                    {
                        foundOrderPrice = order.OrderPrices.ToList().Find(orderPrice => orderPrice.PriceId == price.Id);
                    }
                    if (foundOrderPrice == null)
                    {
                        OrderPrice newOrderPrice = new OrderPrice {
                            Id      = 0,
                            Count   = (int)price.Count,
                            OrderId = order.Id,
                            PriceId = price.Id
                        };
                        _orderPriceRepository.Save(newOrderPrice);
                    }
                });
            });
            return(ConvertOrder(order));
        }
        /// <summary>
        /// Handles CreateOrder button event and open PurchaseView in wizard
        /// </summary>
        private void OnCreateOrder()
        {
            Logger.Default.Append("OnCreateOrder Begin");
            InitCustomer();

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate
            {
                WizardProgressVisibility = Visibility.Visible;

                Customer.Order = Access.CreateOrder(Customer);

                if (Customer.Order != null)
                {
                    PersistSelectedSpots(Customer.Order.Seats);

                    OrderPrice = SelectedSpots.Where(x => x.Result == Core.OperationResult.Success).Sum(x => x.Price);

                    StatusText = OperationResult = String.Format("Заказ № {0} создан. Сумма заказа: {1}", Customer.Order.Id, OrderPrice.ToString("C"));

                    if (_wizardWindow != null)
                    {
                        WizardTitle   = "Оплата заказа";
                        ContentWindow = new PurchaseViewModel(Instance);
                    }

                    _wisardStep = WisardStep.OrderCreated;
                }
                else
                {
                    StatusText = OperationResult = "Произошла ошибка. Места не зарезервированы";
                }
            };
            _worker.RunWorkerCompleted += delegate
            {
                WizardProgressVisibility = Visibility.Collapsed;
            };
            _worker.RunWorkerAsync();

            Logger.Default.Append("OnCreateOrder End");
        }
        /// <summary>
        /// Handles PayOrder button event and open PrintView in wizard
        /// </summary>
        private void OnPayOrder()
        {
            BlankStatus = String.Empty;
            // if View called from orders
            if (Customer.Order.Seats == null)
            {
                Customer.Order.Seats = new List <Seat>();
                foreach (Ticket t in Tickets)
                {
                    Seat seat = new Seat()
                    {
                        Id = t.Id
                    };
                    Customer.Order.Seats.Add(seat);
                }
            }

            Customer.Order.PaymentType =
                (PaymentType)Enum.Parse(typeof(PaymentType), SelectedPaymentType.Key.ToString(), true);

            _worker         = new BackgroundWorker();
            _worker.DoWork += delegate
            {
                WizardProgressVisibility = Visibility.Visible;

                Customer.Order = Access.ConfirmPayment(Customer.Order);

                if (Customer.Order != null && Customer.Order.Status == ItemStatus.Sold)
                {
                    Blank[] blanks = Access.GetBlanks(0, Customer.Order.ItemsCount, ItemStatus.OnSale);

                    if (blanks != null)
                    {
                        if (blanks.Length != Customer.Order.ItemsCount)
                        {
                            BlankStatus = "Количество бланков недостаточно для печати заказа";
                        }
                    }
                    else
                    {
                        BlankStatus = "У вас отсутствуют бланки";
                    }

                    for (int i = 0; i < Customer.Order.Seats.Count; i++)
                    {
                        Seat seat = Customer.Order.Seats[i];
                        Spot spot = SelectedSpots.FirstOrDefault(x => x.Id == seat.Id);
                        if (spot != null)
                        {
                            spot.Status = seat.Status;
                            //spot.Result = seat.Result;
                            spot.ReserveDate = seat.ReserveDate;
                            if (blanks != null && blanks.Length > i)
                            {
                                spot.Blank = blanks[i];
                            }
                        }
                    }

                    //PersistSelectedSpots(Customer.Order.Seats);
                    StatusText          =
                        OperationResult =
                            String.Format("Заказ № {0} оплачен. Сумма заказа: {1}", Customer.Order.Id,
                                          OrderPrice.ToString("C"));

                    if (_wizardWindow != null)
                    {
                        WizardTitle   = "Печать заказа";
                        ContentWindow = new PrintViewModel(Instance);
                    }

                    _wisardStep = WisardStep.OrderPaid;

                    DisplayTickets();
                }
                else
                {
                    Customer.Order      = new Order(); // Just not to be null
                    StatusText          =
                        OperationResult = String.Format("Произошла ошибка. Заказ № {0} не оплачен", Customer.Order.Id);
                }
            };
            _worker.RunWorkerCompleted += delegate
            {
                WizardProgressVisibility = Visibility.Collapsed;
            };
            _worker.RunWorkerAsync();
        }
Beispiel #13
0
    public int Place(string openId)
    {
        if (_fields == null)
        {
            MiniUsers user = new MiniUsers(openId.Trim());
            if (user != null)
            {
                string name = "小程序用户";
                try
                {
                    MiniUsers miniUser = new MiniUsers(openId.Trim());
                    if (!miniUser._fields["nick"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["nick"].ToString().Trim();
                    }
                    if (!miniUser._fields["real_name"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["real_name"].ToString().Trim();
                    }
                }
                catch
                {
                }
                string[,] insertParam = { { "type",                 "varchar", Type.Trim()                                   },
                                          { "open_id",              "varchar", openId.Trim()                                 },
                                          { "cell_number",          "varchar", user._fields["cell_number"].ToString().Trim() },
                                          { "name",                 "varchar", name.Trim()                                   },
                                          { "pay_method",           "varchar", PayMethod.Trim()                              },
                                          { "order_price",          "float",   OrderPrice.ToString()                         },
                                          { "order_real_pay_price", "float",   OrderPrice.ToString()                         },
                                          { "shop",                 "varchar", shop.Trim()                                   },
                                          { "memo",                 "varchar", memo.Trim()                                   } };
                int i = DBHelper.InsertData("order_online", insertParam);

                if (i == 1)
                {
                    int       totalScore = 0;
                    DataTable dt         = DBHelper.GetDataTable(" select top 1 *  from order_online order by [id] desc");
                    int       maxId      = int.Parse(dt.Rows[0][0].ToString());
                    _fields = dt.Rows[0];

                    foreach (OnlineOrderDetail detail in orderDetails)
                    {
                        detail.AddNew(maxId);
                        if (detail.productId > 0)
                        {
                            Product p = new Product(detail.productId);
                            totalScore = totalScore + int.Parse(p._fields["award_score"].ToString().Trim());
                        }
                    }
                    DBHelper.UpdateData("order_online", new string[, ] {
                        { "generate_score", "int", totalScore.ToString() }
                    },
                                        new string[, ] {
                        { "id", "int", maxId.ToString() }
                    }, Util.conStr.Trim());
                    return(maxId);
                }
            }
        }
        return(0);
    }
        static void Main(string[] args)
        {
            UnitOfWork unitOfWork = new UnitOfWork();
            Order      order;
            Atraction  atraction;
            Zone       zone;
            Hero       hero;

            OrderModel     orderModel;
            AtractionModel atractionModel;
            ZoneModel      zoneModel;
            HeroModel      heroModel;

            int    choise    = 0;
            string menu_name = "Menu.txt";
            string filename  = Path.Combine(Environment.CurrentDirectory, menu_name);

            string[] readText = File.ReadAllLines(filename);

            do
            {
                Console.WriteLine("--------------------------------------");
                Console.WriteLine("1. Orders");
                Console.WriteLine("2. Zones");
                Console.WriteLine("3. Atractions");
                Console.WriteLine("4. Heroes");
                Console.WriteLine("5. Exit");
                Console.WriteLine();
                Console.WriteLine("Your choise: ");

                choise = int.Parse(Console.ReadLine());

                switch (choise)
                {
                case 1:    //Orders
                    string       Order_Name, Order_type;
                    int          Order_time, order_zones_count, order_zone_id, order_hero_id, Order_Id;
                    OrderPrice   order_price = new OrderPrice();
                    Hero         order_hero;
                    List <Zone>  order_zones = new List <Zone>();
                    List <Order> all_orders  = unitOfWork.Orders.GetAll().ToList();

                    var config = new MapperConfiguration(cfg => cfg.CreateMap <OrderModel, Order>());
                    var mapper = new Mapper(config);

                    foreach (string s in readText)
                    {
                        Console.WriteLine(s);
                    }
                    choise = int.Parse(Console.ReadLine());

                    if (choise == 1)
                    {
                        orderModel = new OrderModel();

                        Console.WriteLine("Name: ");
                        Order_Name = Console.ReadLine();
                        Console.WriteLine("Type: ");
                        Order_type = Console.ReadLine();
                        Console.WriteLine("Time: ");
                        Order_time = int.Parse(Console.ReadLine());
                        Console.WriteLine("Price: ");
                        order_price.Id    = orderModel.Id;
                        order_price.Price = int.Parse(Console.ReadLine());
                        Console.WriteLine("Hero ID: ");
                        order_hero_id = int.Parse(Console.ReadLine());
                        order_hero    = unitOfWork.Heroes.Get(order_hero_id);
                        Console.WriteLine("Zones count: ");
                        order_zones_count = int.Parse(Console.ReadLine());

                        for (int i = 0; i < order_zones_count; i++)
                        {
                            Console.WriteLine("Zone Id: ");
                            order_zone_id = int.Parse(Console.ReadLine());
                            order_zones.Add(unitOfWork.Zones.Get(order_zone_id));
                        }

                        orderModel.Name       = Order_Name;
                        orderModel.Type       = Order_type;
                        orderModel.Time       = Order_time;
                        orderModel.OrderPrice = order_price;
                        orderModel.HeroId     = orderModel.HeroId;
                        orderModel.Hero       = order_hero;
                        orderModel.Zones      = order_zones;

                        order = mapper.Map <Order>(orderModel);

                        unitOfWork.Orders.Create(order);
                        unitOfWork.Save();
                    }
                    else if (choise == 2)
                    {
                        config = new MapperConfiguration(cfg => cfg.CreateMap <Order, OrderModel>());
                        mapper = new Mapper(config);

                        Console.WriteLine("Id: ");
                        Order_Id = int.Parse(Console.ReadLine());
                        order    = unitOfWork.Orders.Get(Order_Id);
                        var map_order = mapper.Map <OrderModel>(order);
                        Console.WriteLine("Name: ");
                        Order_Name = Console.ReadLine();
                        Console.WriteLine("Type: ");
                        Order_type = Console.ReadLine();
                        Console.WriteLine("Time: ");
                        Order_time = int.Parse(Console.ReadLine());
                        Console.WriteLine("Price: ");
                        order_price.Id    = order.Id;
                        order_price.Price = int.Parse(Console.ReadLine());
                        Console.WriteLine("Hero ID: ");
                        order_hero_id = int.Parse(Console.ReadLine());
                        order_hero    = unitOfWork.Heroes.Get(order_hero_id);
                        Console.WriteLine("Zones count: ");
                        order_zones_count = int.Parse(Console.ReadLine());

                        for (int i = 0; i < order_zones_count; i++)
                        {
                            Console.WriteLine("Zone Id: ");
                            order_zone_id = int.Parse(Console.ReadLine());
                            order_zones.Add(unitOfWork.Zones.Get(order_zone_id));
                        }

                        map_order.Name       = Order_Name;
                        map_order.Type       = Order_type;
                        map_order.Time       = Order_time;
                        map_order.OrderPrice = order_price;
                        map_order.HeroId     = order.HeroId;
                        map_order.Hero       = order_hero;
                        map_order.Zones      = order_zones;

                        config = new MapperConfiguration(cfg => cfg.CreateMap <OrderModel, Order>());
                        mapper = new Mapper(config);

                        order = mapper.Map <Order>(map_order);

                        unitOfWork.Orders.Update(order);
                        unitOfWork.Save();
                    }
                    else if (choise == 3)
                    {
                        Console.WriteLine("Id: ");
                        Order_Id = int.Parse(Console.ReadLine());

                        unitOfWork.Orders.Delete(Order_Id);
                        unitOfWork.Save();
                    }
                    else if (choise == 4)
                    {
                        config = new MapperConfiguration(cfg => cfg.CreateMap <Order, OrderModel>());
                        mapper = new Mapper(config);

                        all_orders = unitOfWork.Orders.GetAll().ToList();
                        var map_orders = mapper.Map <List <OrderModel> >(all_orders);

                        foreach (var o in map_orders)
                        {
                            o.Hero = unitOfWork.Heroes.Get(o.HeroId);

                            Console.WriteLine("-------------------------------");
                            Console.WriteLine("Id: " + o.Id);
                            Console.WriteLine("Name: " + o.Name);
                            Console.WriteLine("Type: " + o.Type);
                            Console.WriteLine("Time: " + o.Time);
                            Console.WriteLine("Hero: " + o.Hero.Name);
                            foreach (var z in o.Zones)
                            {
                                Console.WriteLine("Zone: " + z.Name);
                            }
                            Console.WriteLine("Price: " + o.OrderPrice.Price);
                        }
                    }

                    break;

                case 2:    //Zones
                    string           ZoneName, ZoneType;
                    int              ZoneId, zone_atractions_count, zone_atraction_id, zone_orders_count, zone_order_id;
                    List <Order>     Zone_orders     = new List <Order>();
                    List <Atraction> Zone_atractions = new List <Atraction>();
                    List <Zone>      all_zones       = unitOfWork.Zones.GetAll().ToList();

                    var config2 = new MapperConfiguration(cfg => cfg.CreateMap <ZoneModel, Zone>());
                    var mapper2 = new Mapper(config2);

                    foreach (string s in readText)
                    {
                        Console.WriteLine(s);
                    }
                    choise = int.Parse(Console.ReadLine());

                    if (choise == 1)
                    {
                        zoneModel = new ZoneModel();

                        Console.WriteLine("Name: ");
                        ZoneName = Console.ReadLine();
                        Console.WriteLine("Type: ");
                        ZoneType = Console.ReadLine();
                        Console.WriteLine("Atractions count: ");
                        zone_atractions_count = int.Parse(Console.ReadLine());

                        for (int i = 0; i < zone_atractions_count; i++)
                        {
                            Console.WriteLine("Atraction Id: ");
                            zone_atraction_id = int.Parse(Console.ReadLine());
                            Zone_atractions.Add(unitOfWork.Atractions.Get(zone_atraction_id));
                        }

                        zoneModel.Name       = ZoneName;
                        zoneModel.Type       = ZoneType;
                        zoneModel.Atractions = Zone_atractions;

                        zone = mapper2.Map <Zone>(zoneModel);

                        unitOfWork.Zones.Create(zone);
                        unitOfWork.Save();
                    }
                    else if (choise == 2)
                    {
                        Console.WriteLine("Id: ");
                        ZoneId = int.Parse(Console.ReadLine());
                        Console.WriteLine("Name: ");
                        ZoneName = Console.ReadLine();
                        Console.WriteLine("Type: ");
                        ZoneType = Console.ReadLine();
                        Console.WriteLine("Atractions count: ");
                        zone_atractions_count = int.Parse(Console.ReadLine());

                        for (int i = 0; i < zone_atractions_count; i++)
                        {
                            Console.WriteLine("Atraction Id: ");
                            zone_atraction_id = int.Parse(Console.ReadLine());
                            Zone_atractions.Add(unitOfWork.Atractions.Get(zone_atraction_id));
                        }

                        Console.WriteLine("Orders count: ");
                        zone_orders_count = int.Parse(Console.ReadLine());

                        for (int i = 0; i < zone_orders_count; i++)
                        {
                            Console.WriteLine("Order Id: ");
                            zone_order_id = int.Parse(Console.ReadLine());
                            Zone_orders.Add(unitOfWork.Orders.Get(zone_order_id));
                        }

                        config2 = new MapperConfiguration(cfg => cfg.CreateMap <Zone, ZoneModel>());
                        mapper2 = new Mapper(config2);
                        zone    = unitOfWork.Zones.Get(ZoneId);
                        var map_zone = mapper2.Map <ZoneModel>(zone);

                        map_zone.Name       = ZoneName;
                        map_zone.Type       = ZoneType;
                        map_zone.Atractions = Zone_atractions;
                        map_zone.Orders     = Zone_orders;

                        config2 = new MapperConfiguration(cfg => cfg.CreateMap <ZoneModel, Zone>());
                        mapper2 = new Mapper(config2);
                        zone    = mapper2.Map <Zone>(map_zone);

                        unitOfWork.Zones.Update(zone);
                        unitOfWork.Save();
                    }
                    else if (choise == 3)
                    {
                        Console.WriteLine("Id: ");
                        ZoneId = int.Parse(Console.ReadLine());

                        unitOfWork.Zones.Delete(ZoneId);
                        unitOfWork.Save();
                    }
                    else if (choise == 4)
                    {
                        config2 = new MapperConfiguration(cfg => cfg.CreateMap <Zone, ZoneModel>());
                        mapper2 = new Mapper(config2);

                        all_zones = unitOfWork.Zones.GetAll().ToList();
                        var map_zones = mapper2.Map <List <ZoneModel> >(all_zones);

                        foreach (var z in map_zones)
                        {
                            Console.WriteLine("-------------------------------");
                            Console.WriteLine("Id: " + z.Id);
                            Console.WriteLine("Name: " + z.Name);
                            Console.WriteLine("Type: " + z.Type);
                            foreach (var a in z.Atractions)
                            {
                                Console.WriteLine("Atraction: " + a.Name);
                            }
                        }
                    }

                    break;

                case 3:    //Atractions
                    string           AtractionName, AtractionType;
                    int              Capacity, zones_count, zone_id, atraction_id;
                    List <Zone>      zones          = new List <Zone>();
                    List <Atraction> all_atractions = unitOfWork.Atractions.GetAll().ToList();

                    var config3 = new MapperConfiguration(cfg => cfg.CreateMap <AtractionModel, Atraction>());
                    var mapper3 = new Mapper(config3);

                    foreach (string s in readText)
                    {
                        Console.WriteLine(s);
                    }
                    choise = int.Parse(Console.ReadLine());

                    if (choise == 1)
                    {
                        atractionModel = new AtractionModel();

                        Console.WriteLine("Name: ");
                        AtractionName = Console.ReadLine();
                        Console.WriteLine("Atraction Type: ");
                        AtractionType = Console.ReadLine();
                        Console.WriteLine("Capacity: ");
                        Capacity = int.Parse(Console.ReadLine());

                        atractionModel.Name     = AtractionName;
                        atractionModel.Type     = AtractionType;
                        atractionModel.Capacity = Capacity;

                        atraction = mapper3.Map <Atraction>(atractionModel);

                        unitOfWork.Atractions.Create(atraction);
                        unitOfWork.Save();
                    }
                    else if (choise == 2)
                    {
                        Console.WriteLine("Enter id: ");
                        atraction_id = int.Parse(Console.ReadLine());
                        Console.WriteLine("Name: ");
                        AtractionName = Console.ReadLine();
                        Console.WriteLine("Atraction Type: ");
                        AtractionType = Console.ReadLine();
                        Console.WriteLine("Capacity: ");
                        Capacity = int.Parse(Console.ReadLine());
                        Console.WriteLine("Zones count: ");
                        zones_count = int.Parse(Console.ReadLine());
                        for (int i = 0; i < zones_count; i++)
                        {
                            Console.WriteLine("Enter zone id: ");
                            zone_id = int.Parse(Console.ReadLine());
                            zones.Add(unitOfWork.Zones.Get(zone_id));
                        }

                        atraction      = unitOfWork.Atractions.Get(atraction_id);
                        config3        = new MapperConfiguration(cfg => cfg.CreateMap <Atraction, AtractionModel>());
                        mapper3        = new Mapper(config3);
                        atractionModel = mapper3.Map <AtractionModel>(atraction);


                        atractionModel.Name     = AtractionName;
                        atractionModel.Type     = AtractionType;
                        atractionModel.Capacity = Capacity;
                        atractionModel.Zones    = zones;

                        config3   = new MapperConfiguration(cfg => cfg.CreateMap <AtractionModel, Atraction>());
                        mapper3   = new Mapper(config3);
                        atraction = mapper3.Map <Atraction>(atractionModel);

                        unitOfWork.Atractions.Update(atraction);
                        unitOfWork.Save();
                    }
                    else if (choise == 3)
                    {
                        Console.WriteLine("Enter id: ");
                        atraction_id = int.Parse(Console.ReadLine());

                        unitOfWork.Atractions.Delete(atraction_id);
                        unitOfWork.Save();
                    }
                    else if (choise == 4)
                    {
                        config3 = new MapperConfiguration(cfg => cfg.CreateMap <Atraction, AtractionModel>());
                        mapper3 = new Mapper(config3);

                        all_atractions = unitOfWork.Atractions.GetAll().ToList();
                        var map_atractions = mapper3.Map <List <AtractionModel> >(all_atractions);

                        foreach (var a in map_atractions)
                        {
                            Console.WriteLine("-------------------------------");
                            Console.WriteLine("Id: " + a.Id);
                            Console.WriteLine("Name: " + a.Name);
                            Console.WriteLine("Type: " + a.Type);
                            Console.WriteLine("Capacity: " + a.Capacity);
                            foreach (var z in a.Zones)
                            {
                                Console.WriteLine("Zone: " + z.Name);
                            }
                        }
                    }

                    break;

                case 4:     //Heroes
                    string       HeroName;
                    int          heroId;
                    int          orders_count;
                    int          order_id;
                    List <Order> hero_orders = new List <Order>();
                    List <Hero>  heroes;
                    var          config4 = new MapperConfiguration(cfg => cfg.CreateMap <HeroModel, Hero>());
                    var          mapper4 = new Mapper(config4);

                    foreach (string s in readText)
                    {
                        Console.WriteLine(s);
                    }
                    choise = int.Parse(Console.ReadLine());

                    if (choise == 1)
                    {
                        //hero = new Hero();
                        heroModel = new HeroModel();

                        Console.WriteLine("Name: ");
                        HeroName = Console.ReadLine();

                        heroModel.Name = HeroName;

                        hero = mapper4.Map <Hero>(heroModel);

                        unitOfWork.Heroes.Create(hero);
                        unitOfWork.Save();
                    }
                    else if (choise == 2)
                    {
                        Console.WriteLine("Enter id: ");
                        heroId = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter Name: ");
                        HeroName = Console.ReadLine();
                        Console.WriteLine("Enter orders count: ");
                        orders_count = int.Parse(Console.ReadLine());
                        for (int i = 0; i < orders_count; i++)
                        {
                            Console.WriteLine("Enter order id: ");
                            order_id = int.Parse(Console.ReadLine());
                            hero_orders.Add(unitOfWork.Orders.Get(order_id));
                        }

                        hero = unitOfWork.Heroes.Get(heroId);

                        config4 = new MapperConfiguration(cfg => cfg.CreateMap <Hero, HeroModel>());
                        mapper4 = new Mapper(config4);

                        var map_hero = mapper4.Map <HeroModel>(hero);

                        map_hero.Name   = HeroName;
                        map_hero.Orders = hero_orders;

                        config4 = new MapperConfiguration(cfg => cfg.CreateMap <HeroModel, Hero>());
                        mapper4 = new Mapper(config4);

                        hero = mapper4.Map <Hero>(map_hero);

                        unitOfWork.Heroes.Update(hero);
                        unitOfWork.Save();
                    }
                    else if (choise == 3)
                    {
                        Console.WriteLine("Enter id: ");
                        heroId = int.Parse(Console.ReadLine());

                        unitOfWork.Heroes.Delete(heroId);
                        unitOfWork.Save();
                    }
                    else if (choise == 4)
                    {
                        config4 = new MapperConfiguration(cfg => cfg.CreateMap <Hero, HeroModel>());
                        mapper4 = new Mapper(config4);

                        heroes = unitOfWork.Heroes.GetAll().ToList();
                        var map_heroes = mapper4.Map <List <HeroModel> >(unitOfWork.Heroes.GetAll().ToList());
                        foreach (var h in map_heroes)
                        {
                            Console.WriteLine("-------------------------------");
                            Console.WriteLine("Id: " + h.HeroId);
                            Console.WriteLine("Name: " + h.Name);
                            foreach (var o in h.Orders)
                            {
                                Console.WriteLine("Order: " + o.Name);
                            }
                        }
                    }

                    break;
                }
            } while (choise != 5);
        }