Example #1
0
        public void Run()
        {
            while (true)
            {
                ConstantInformation.PrintAvailableKeyCodes();
                var keyCommand = ConsoleInput.ReadLine();
                switch (keyCommand)
                {
                case "1":
                {
                    RegistrationModel.RegisterUser();
                }
                    return;

                case "2":
                {
                    var user = LoginModel.UserLogin();

                    ICommandParser        comandParser = new CommandParser();
                    ICorierServiceContext dbContext    = new CorierServiceContext();
                    var entryPointSQL = new EntryPointToSQL(dbContext, comandParser);

                    while (true)
                    {
                        int userId     = user[0].Id;
                        int userTypeId = user[0].UserTypeId;

                        if (userTypeId == 1)
                        {
                            entryPointSQL.AssignItams(userId);
                            return;
                        }
                        else
                        {
                            entryPointSQL.CommitDistribution(userId);
                            return;
                        }
                    }
                }

                case "3":
                {
                    ConsoleOutput.PrintLine(Constant.EXIT_SUCCESSFUL);
                }
                    return;

                default:
                {
                    ConsoleOutput.PrintLine(Constant.WRONG_SYMBOL);
                }
                break;
                }
            }
        }
        internal void AddOffices()
        {
            var dbContext = new CorierServiceContext();

            var office1 = new Office
            {
                Address = "ул. Мария Луиза 56",
                City    = dbContext.Cities.Find(2)
            };

            var office2 = new Office
            {
                Address = "кв. Павлово, ул. Незабравка 167",
                City    = dbContext.Cities.Find(2)
            };

            var office3 = new Office
            {
                Address = "ул. Аполония 42",
                City    = dbContext.Cities.Find(1)
            };

            var office4 = new Office
            {
                Address = "кв. Храбрино бл.28 вх.А ет.3 ап.67",
                City    = dbContext.Cities.Find(4)
            };

            var office5 = new Office
            {
                Address = "ул.Детелина 79",
                City    = dbContext.Cities.Find(3)
            };

            var office6 = new Office
            {
                Address = "кв. Слатина бл.53 вх.Д ет.12 ап.73",
                City    = dbContext.Cities.Find(2)
            };

            dbContext.Offices.Add(office1);
            dbContext.Offices.Add(office2);
            dbContext.Offices.Add(office3);
            dbContext.Offices.Add(office4);
            dbContext.Offices.Add(office5);
            dbContext.Offices.Add(office6);

            dbContext.SaveChanges();
        }
Example #3
0
        internal void AddCities()
        {
            var dbContext = new CorierServiceContext();

            var city1 = new City()
            {
                CityName = "Созопол"
            };
            var city2 = new City()
            {
                CityName = "София"
            };
            var city3 = new City()
            {
                CityName = "Монтана"
            };
            var city4 = new City()
            {
                CityName = "Карлово"
            };
            var city5 = new City()
            {
                CityName = "Айтос"
            };
            var city6 = new City()
            {
                CityName = "Хасково"
            };
            var city7 = new City()
            {
                CityName = "Варна"
            };

            dbContext.Cities.Add(city1);
            dbContext.Cities.Add(city2);
            dbContext.Cities.Add(city3);
            dbContext.Cities.Add(city4);
            dbContext.Cities.Add(city5);
            dbContext.Cities.Add(city6);
            dbContext.Cities.Add(city7);

            dbContext.SaveChanges();
        }
        internal void AddServiceTypes()
        {
            var dbContext = new CorierServiceContext();

            var serviceType1 = new ServicesType()
            {
                ServiceType = "Regular"
            };
            var serviceType2 = new ServicesType {
                ServiceType = "Express"
            };
            var serviceType3 = new ServicesType {
                ServiceType = "Economy"
            };

            dbContext.ServicesTypes.Add(serviceType1);
            dbContext.ServicesTypes.Add(serviceType2);
            dbContext.ServicesTypes.Add(serviceType3);

            dbContext.SaveChanges();
        }
        internal void AddServiceOptions()
        {
            var dbContext = new CorierServiceContext();

            var servOption1 = new ServiceOption()
            {
                Weight       = 5,
                Price        = 8.99m,
                TimeDuration = 3,
                ServicesType = dbContext.ServicesTypes.Find(1)
            };

            var servOption2 = new ServiceOption()
            {
                Weight       = 10,
                Price        = 15.60m,
                TimeDuration = 3,
                ServicesType = dbContext.ServicesTypes.Find(1)
            };

            var servOption3 = new ServiceOption()
            {
                Weight       = 15,
                Price        = 22.30m,
                TimeDuration = 3,
                ServicesType = dbContext.ServicesTypes.Find(1)
            };

            var servOption4 = new ServiceOption()
            {
                Weight       = 5,
                Price        = 16.30m,
                TimeDuration = 2,
                ServicesType = dbContext.ServicesTypes.Find(2)
            };

            var servOption5 = new ServiceOption()
            {
                Weight       = 10,
                Price        = 34.80m,
                TimeDuration = 2,
                ServicesType = dbContext.ServicesTypes.Find(2)
            };

            var servOption6 = new ServiceOption()
            {
                Weight       = 15,
                Price        = 60.28m,
                TimeDuration = 1,
                ServicesType = dbContext.ServicesTypes.Find(2)
            };

            var servOption7 = new ServiceOption()
            {
                Weight       = 5,
                Price        = 7.80m,
                TimeDuration = 5,
                ServicesType = dbContext.ServicesTypes.Find(3)
            };

            var servOption8 = new ServiceOption()
            {
                Weight       = 10,
                Price        = 11.20m,
                TimeDuration = 5,
                ServicesType = dbContext.ServicesTypes.Find(3)
            };

            var servOption9 = new ServiceOption()
            {
                Weight       = 15,
                Price        = 18.46m,
                TimeDuration = 5,
                ServicesType = dbContext.ServicesTypes.Find(3)
            };

            dbContext.ServiceOptions.Add(servOption1);
            dbContext.ServiceOptions.Add(servOption2);
            dbContext.ServiceOptions.Add(servOption3);
            dbContext.ServiceOptions.Add(servOption4);
            dbContext.ServiceOptions.Add(servOption5);
            dbContext.ServiceOptions.Add(servOption6);
            dbContext.ServiceOptions.Add(servOption7);
            dbContext.ServiceOptions.Add(servOption8);
            dbContext.ServiceOptions.Add(servOption9);

            dbContext.SaveChanges();
        }
        internal void AddServices()
        {
            var dbContext = new CorierServiceContext();

            var service1 = new Service()
            {
                Details       = "Лаптоп",
                IsTaken       = false,
                City          = dbContext.Cities.Find(1),
                ServiceOption = dbContext.ServiceOptions.Find(7),
                CreateDate    = DateTime.Now,
                OfficeId      = 1,
                IsCompleted   = false,
                UserId        = 1
            };

            var service2 = new Service()
            {
                Details       = "Монитор",
                IsTaken       = false,
                City          = dbContext.Cities.Find(5),
                ServiceOption = dbContext.ServiceOptions.Find(5),
                CreateDate    = DateTime.Now,
                OfficeId      = 3,
                IsCompleted   = false,
                UserId        = 1
            };

            var service3 = new Service()
            {
                Details       = "Книги",
                IsTaken       = false,
                City          = dbContext.Cities.Find(4),
                ServiceOption = dbContext.ServiceOptions.Find(3),
                CreateDate    = DateTime.Now,
                OfficeId      = 6,
                IsCompleted   = false,
                UserId        = 1
            };

            var service4 = new Service()
            {
                Details       = "Холна маса",
                IsTaken       = false,
                City          = dbContext.Cities.Find(2),
                ServiceOption = dbContext.ServiceOptions.Find(8),
                CreateDate    = DateTime.Now,
                OfficeId      = 4,
                IsCompleted   = false,
                UserId        = 2
            };

            var service5 = new Service()
            {
                Details       = "Дрехи",
                IsTaken       = false,
                City          = dbContext.Cities.Find(1),
                ServiceOption = dbContext.ServiceOptions.Find(5),
                CreateDate    = DateTime.Now,
                OfficeId      = 1,
                IsCompleted   = false,
                UserId        = 2
            };

            var service6 = new Service()
            {
                Details       = "Канцеларски материали",
                IsTaken       = false,
                City          = dbContext.Cities.Find(4),
                ServiceOption = dbContext.ServiceOptions.Find(2),
                CreateDate    = DateTime.Now,
                OfficeId      = 1,
                IsCompleted   = false,
                UserId        = 3
            };

            dbContext.Services.Add(service1);
            dbContext.Services.Add(service2);
            dbContext.Services.Add(service3);
            dbContext.Services.Add(service4);
            dbContext.Services.Add(service5);
            dbContext.Services.Add(service6);

            dbContext.SaveChanges();
        }