public ActionResult Edit(int? id)
        {
            CitiesService citiesService = new CitiesService();

            CitiesEditVM model = new CitiesEditVM();
            City city;

            if (!id.HasValue)
            {
                city = new City();
            }
            else
            {
                city = citiesService.GetByID(id.Value);
                if (city == null)
                {
                    return RedirectToAction("List");
                }
            }

            model.ID = city.ID;
            model.Name = city.Name;
            model.PostCode = city.PostCode;
            model.CountryID = city.CountryID;

            //model.Countries = new CountriesRepository().GetAll(); 1
            //model.Countries = new SelectList(new CountriesRepository().GetAll(), "ID", "Name"); //2
            model.Countries = citiesService.GetSelectedCountries(); // 3

            return View(model);
        }
        public ActionResult Delete(int? id)
        {
            CitiesService citiesService = new CitiesService();

            if (!id.HasValue)
            {
                return RedirectToAction("List");
            }

            citiesService.Delete(id.Value);

            return RedirectToAction("List");
        }
Exemple #3
0
        public void ReturnNull_WhenNameIsNull()
        {
            // Arrange
            var repoMock      = new Mock <IEfRepository <City> >();
            var dbContextMock = new Mock <ISaveContext>();

            CitiesService citiesService = new CitiesService(repoMock.Object, dbContextMock.Object);

            // Act
            City city = citiesService.GetByName(null);

            // Assert
            Assert.IsNull(city);
        }
Exemple #4
0
        public void CanRemoveCity_CitiesService()
        {
            using (var context = new TicketsResellingContext(ContextOptions))
            {
                var citiesService = new CitiesService(context);

                citiesService.RemoveCity(2);

                var cities = citiesService.GetCities().Result.ToList();

                cities.Count().Should().Be(2);
                cities[0].Name.Should().Be("Tallin");
                cities[1].Name.Should().Be("Riga");
            }
        }
Exemple #5
0
        public async Task AddAsyncThrowsWhenTheInputModelIsNull()
        {
            // Arrange
            var mapperMock     = new Mock <IMapper>();
            var repositoryMock = new Mock <IDeletableEntityRepository <City> >();

            var citiesService = new CitiesService(repositoryMock.Object, mapperMock.Object);

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                // Act
                await citiesService.AddAsync(null, new ImageInputModel());
            });
        }
Exemple #6
0
        public AddressesServiceTests()
        {
            this.addressList   = new List <Address>();
            this.addressesRepo = new Mock <IDeletableEntityRepository <Address> >();
            this.addressesRepo.Setup(x => x.All()).Returns(this.addressList.AsQueryable());
            this.addressesRepo.Setup(x => x.AddAsync(It.IsAny <Address>())).Callback((Address address) => this.addressList.Add(address));

            this.citiesList = new List <City>();
            this.citiesRepo = new Mock <IRepository <City> >();
            this.citiesRepo.Setup(x => x.All()).Returns(this.citiesList.AsQueryable());
            this.citiesRepo.Setup(x => x.AddAsync(It.IsAny <City>())).Callback((City city) => this.citiesList.Add(city));

            this.citiesService    = new CitiesService(this.citiesRepo.Object);
            this.addressesService = new AddressesService(this.addressesRepo.Object, this.citiesService);
        }
Exemple #7
0
    public void DdlCities()
    {
        //בניית רשימת ערים
        DataSet ds = CitiesService.GetDataSet();

        city.DataSource     = ds;
        city.DataTextField  = "CityName";
        city.DataValueField = "CityId";
        city.DataBind();
        ListItem li = new ListItem();

        li.Value = "FirstCity";
        li.Text  = "choose city";
        city.Items.Insert(0, li);
    }
        public async Task GetByCountryIdWithTeamsWithServicesGenericWorksCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);
            var city    = new City()
            {
                Id        = 1,
                CountryId = 1,
            };

            var city2 = new City()
            {
                Id        = 2,
                CountryId = 1,
                Teams     = new List <Team>()
                {
                    new Team()
                    {
                        Services = new List <TeamService>()
                        {
                            new TeamService()
                        }
                    }
                },
            };

            var city3 = new City()
            {
                Id        = 3,
                CountryId = 2,
            };

            dbContext.Add(city);
            dbContext.Add(city2);
            dbContext.Add(city3);
            await dbContext.SaveChangesAsync();

            var cities = await service.GetByCountryIdAsync(1, true);

            Assert.Single(cities);
        }
        public async Task GetAllGenericShouldWork()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "GetAllGenericCities").Options;
            var dbContext = new ApplicationDbContext(options);

            dbContext.Cities.Add(new City());
            dbContext.Cities.Add(new City());
            dbContext.Cities.Add(new City());
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <City>(dbContext);
            var service    = new CitiesService(repository);

            Assert.Equal(3, service.GetAll <City>().Count());
        }
Exemple #10
0
        public void CanGetCitiesByStatus_CitiesService()
        {
            using (var context = new TicketsResellingContext(ContextOptions))
            {
                var citiesService = new CitiesService(context);

                var citiesAvaliable    = citiesService.GetCityesByStatus(CityStatuses.Avaliable).Result.ToList();
                var citiesNotAvaliable = citiesService.GetCityesByStatus(CityStatuses.NotAvaliable).Result.ToList();
                var citiesRemoved      = citiesService.GetCityesByStatus(CityStatuses.Removed).Result.ToList();

                citiesAvaliable.Count().Should().Be(2);
                citiesNotAvaliable.Count().Should().Be(1);
                citiesRemoved.Count().Should().Be(0);
                citiesNotAvaliable[0].Name.Should().Be("Tallin");
            }
        }
        public void GetCitiesTest()
        {
            var mockRepository = new Mock <IDeletableEntityRepository <City> >();

            mockRepository.Setup(x => x.All()).Returns(this.GetCityData());

            var service = new CitiesService(mockRepository.Object);

            var cityNames = service.GetCities();

            var result = new List <string> {
                "Sofia", "Plovdiv", "Tokyo"
            }.OrderBy(n => n);

            Assert.Equal(result, cityNames);
        }
Exemple #12
0
        public void CanMakeCityAndAllItsVenuesNotAvaliable_CitiesService()
        {
            using (var context = new TicketsResellingContext(ContextOptions))
            {
                var citiesService = new CitiesService(context);
                var venueService  = new VenuesService(context);

                citiesService.MakeCityAndAllItsVenuesNotAvaliable(2);

                var city   = citiesService.GetCityById(2).Result;
                var venues = venueService.GetVenuesByStatuses(VenueStatuses.NotAvaliable).Result.ToList();

                city.Status.Should().Be(CityStatuses.NotAvaliable);
                venues.Count.Should().Be(4);
            }
        }
Exemple #13
0
        public void GetCitiesAsyncTest()
        {
            base.ClearAll();

            var mockHttpService = new HttpService();

            Ioc.RegisterSingleton <IHttpService>(mockHttpService);

            var mockJsonConverter = new JsonConverter();

            Ioc.RegisterSingleton <IJsonConverter>(mockJsonConverter);

            var service = new CitiesService(mockHttpService, mockJsonConverter);

            NUnit.Framework.Assert.IsNotNull(service.GetCitiesAsync("Belarus").Result);
        }
Exemple #14
0
        public void CanAddCity_CitiesService()
        {
            using (var context = new TicketsResellingContext(ContextOptions))
            {
                var citiesService = new CitiesService(context);

                var city = new City {
                    Name = "Berlin", Status = CityStatuses.Avaliable
                };
                citiesService.AddCity(city);
                var cities = citiesService.GetCities().Result.ToList();

                cities.Count().Should().Be(4);
                cities[3].Name.Should().Be("Berlin");
            }
        }
Exemple #15
0
 public MaidsController(IUnitOfWork unitOfWork, MaidsService service,
                        MaidEmploymentHistoriesService maidEmploymentHistoriesService, MaidLanguagesService maidLanguagesService,
                        MaidSkillsService maidSkillsService, MaidDocumentsService maidDocumentsService,
                        AgenciesService agenciesService, CitiesService citiesService, NationalitiesService nationalitiesService,
                        VisaStatusService visaStatusService, AgencyPacksService agencyPacksService)
     : base(unitOfWork, service)
 {
     _maidEmploymentHistoriesService = maidEmploymentHistoriesService;
     _maidLanguagesService           = maidLanguagesService;
     _maidSkillsService    = maidSkillsService;
     _maidDocumentsService = maidDocumentsService;
     _agenciesService      = agenciesService;
     _citiesService        = citiesService;
     _nationalitiesService = nationalitiesService;
     _visaStatusService    = visaStatusService;
     _agencyPacksService   = agencyPacksService;
 }
        public async Task CreateAsyncWorksCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);

            await service.CreateAsync("1", 1);

            var result = dbContext.Cities.FirstOrDefault(c => c.Name == "1");

            Assert.NotNull(result);
        }
        public async Task DeleteCityAsync_Should_Throw_ObjectNotFoundException()
        {
            var city = new City()
            {
                CityId = 1, Name = "Stockholm"
            };

            var mockedRepository = new Mock <ICitiesRepository>();

            var mapperConfiguration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DomainProfile());
            });
            var mockedMapper = mapperConfiguration.CreateMapper();

            var cityService = new CitiesService(mockedRepository.Object, mockedMapper);

            await Assert.ThrowsAsync <ObjectNotFoundException>(() => cityService.DeleteCityAsync(2));
        }
        internal static void Configure()
        {
            Dictionary <string, string[]> locations = new Dictionary <string, string[]>();

            using (WebClient webClient = new WebClient())
            {
                string jsonString = webClient.DownloadString("https://raw.githubusercontent.com/David-Haim/CountriesToCitiesJSON/master/countriesToCities.json");
                locations = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(jsonString);
            }

            CountriesService countriesService = new CountriesService();
            List <Country>   countries        = new List <Country>();

            foreach (var item in locations)
            {
                Country country = new Country();
                country.Name = item.Key;
                countries.Add(country);
            }

            countriesService.InsertCollection(countries);

            List <Country> allCountries = countriesService.GetAll();
            List <City>    cities       = new List <City>();

            foreach (var item in locations)
            {
                foreach (Country c in allCountries)
                {
                    if (c.Name == item.Key)
                    {
                        cities.AddRange(item.Value.Select(city => new City()
                        {
                            Name = city, CountryID = c.ID
                        }));
                    }
                }
            }

            CitiesService citieService = new CitiesService();

            citieService.InsertCollection(cities);
        }
Exemple #19
0
        public void ReturnNull_WhenThereIsNoModelWithThePassedName()
        {
            // Arrange
            var repoMock      = new Mock <IEfRepository <City> >();
            var dbContextMock = new Mock <ISaveContext>();

            repoMock.Setup(m => m.Add(new City()
            {
                Name = "PeshoCity"
            }));

            CitiesService citiesService = new CitiesService(repoMock.Object, dbContextMock.Object);

            // Act
            City city = citiesService.GetByName("Pesho");

            // Assert
            Assert.IsNull(city);
        }
Exemple #20
0
        public ApplicationViewModel()
        {
            Steps = new StepsViewModel();

            StartCommand           = new DelegateCommand(obj => Start());
            ContinueCommand        = new DelegateCommand(obj => Continue());
            StepForwardCommand     = new DelegateCommand(obj => StepForward());
            ClearPopulationCommand = new DelegateCommand(obj => ClearPopulation());

            _citiesService = new CitiesService(srcFilePath);
            //var path = new int[] { 1, 8, 38, 31, 44, 18, 7, 28, 6, 37, 19, 27, 17, 43, 30, 36, 46, 33, 20, 47, 21, 32, 39, 48, 5, 42, 24, 10, 45, 35, 4, 26, 2, 29, 34, 41, 16, 22, 3, 23, 14, 25, 13, 11, 12, 15, 40, 9 };
            //var cities = new City[path.Length];
            //for (int i = 0; i < path.Length; i++)
            //{
            //    var city = _citiesService.Cities.First(c => c.number == (path[i] - 1));
            //    cities[i] = city;
            //}
            //var dist = CountSumDistance(cities);
            //int a = 0;
        }
Exemple #21
0
        private async Task SetCitiesToAsync()
        {
            var citiesService = new CitiesService(_httpService, _jsonConverter);

            _dataOfFlights.CountryTo = SelectedCountryTo;
            var citiesTo = await citiesService.GetCitiesAsync(SelectedCountryTo);

            if (citiesTo != null)
            {
                ItemsCitiesTo.AutoCompleteList.Clear();
                ItemsCitiesTo.AutoCompleteList = citiesTo;
                IsAirportToExist        = true;
                _dataOfFlights.CitiesTo = citiesTo;
                RaisePropertyChanged(() => ItemsCitiesTo);
            }
            else
            {
                IsAirportToExist        = false;
                _dataOfFlights.CitiesTo = null;
            }
        }
        public async Task DeleteByCountryIdWorksCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);
            var city    = new City()
            {
                Id        = 1,
                CountryId = 1,
            };

            var city2 = new City()
            {
                Id        = 2,
                CountryId = 1,
            };

            var city3 = new City()
            {
                Id        = 3,
                CountryId = 2,
            };

            dbContext.Add(city);
            dbContext.Add(city2);
            dbContext.Add(city3);
            await dbContext.SaveChangesAsync();

            await service.DeleteByCountryIdAsync(1);

            var citiesInDb = dbContext.Cities.ToList();

            Assert.Single(citiesInDb);
        }
        public async Task TestGetAllCities()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("Cities");

            var cityRepository = new EfDeletableEntityRepository <City>(new ApplicationDbContext(options.Options));

            await cityRepository.AddAsync(new City { Name = "София" });

            await cityRepository.AddAsync(new City { Name = "Стара Загора" });

            await cityRepository.AddAsync(new City { Name = "Пловдив" });

            await cityRepository.SaveChangesAsync();

            var cityService = new CitiesService(cityRepository);

            AutoMapperConfig.RegisterMappings(typeof(MyTestCity).Assembly);
            var cities = cityService.GetAll <MyTestCity>();

            Assert.Equal(3, cities.Count());
        }
        public void AddingCities()
        {
            var list     = new List <City>();
            var mockRepo = new Mock <IDeletableEntityRepository <City> >();

            mockRepo.Setup(x => x.AllAsNoTracking()).Returns(list.AsQueryable());
            mockRepo.Setup(x => x.AddAsync(It.IsAny <City>()));
            var service = new CitiesService(mockRepo.Object);
            var city    = new City
            {
                Id   = 1,
                Name = "Sofia",
            };

            list.Add(city);
            var expected = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("1", "Sofia"),
            };

            Assert.Equal(expected, service.GetAllAsKeyValuePairs());
        }
        public async Task GetAllAsyncWorksCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);
            var city    = new City()
            {
                Id        = 1,
                CountryId = 1,
            };

            var city2 = new City()
            {
                Id        = 2,
                CountryId = 1,
            };

            var city3 = new City()
            {
                Id        = 3,
                CountryId = 2,
            };

            dbContext.Add(city);
            dbContext.Add(city2);
            dbContext.Add(city3);
            await dbContext.SaveChangesAsync();

            var result = await service.GetAllAsync <CityServiceModel>();

            Assert.Equal(3, result.Count());
        }
        public void GetOrCreate_GivenExistingName_ShouldReturnCityWithThatName()
        {
            // arrange
            string name = "test";

            Mock <IDbRepository <City> > mockRepository = new Mock <IDbRepository <City> >();

            mockRepository.Setup(x => x.GetAll())
            .Returns(new List <City>()
            {
                new City()
                {
                    Id = 1, Name = "test"
                },
                new City()
                {
                    Id = 2, Name = "another test"
                }
            }.AsQueryable());

            mockRepository
            .Setup(x => x.CreateAsync(It.Is <City>(city => city.Name == "test")))
            .Returns(Task.FromResult(new City()
            {
                Id = 1, Name = "test"
            }));

            ICitiesService service = new CitiesService(mockRepository.Object);

            // act
            Func <Task> action = async() => await service.GetOrCreateAsync(name);

            // assert
            action.Should().Equals(new City()
            {
                Id = 1, Name = name
            });
        }
        public async Task GetByIdShouldReturnWhenCityDoesntExists()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);
            var city    = new City()
            {
                Id = 1,
            };

            dbContext.Add(city);
            await dbContext.SaveChangesAsync();

            var cities = await service.GetByIdAsync <CityServiceModel>(3);

            Assert.Null(cities);
        }
        public async Task CheckIfCityExistsAsyncReturnsFalseIfCityDoesntExists()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <City>(dbContext);

            var service = new CitiesService(repository, addressesService.Object);
            var city    = new City()
            {
                Id = 1,
            };

            dbContext.Add(city);
            await dbContext.SaveChangesAsync();

            var result = await service.CheckIfCityExistsAsync(2);

            Assert.False(result);
        }
        public ActionResult Edit()
        {
            CitiesService citiesService = new CitiesService();

            CitiesEditVM model = new CitiesEditVM();
            TryUpdateModel(model);

            if (!ModelState.IsValid)
            {
                model.Countries = citiesService.GetSelectedCountries();
                return View(model);
            }

            City city;
            if (model.ID == 0)
            {
                city = new City();
            }
            else
            {
                city = citiesService.GetByID(model.ID);
                if (city == null)
                {
                    return RedirectToAction("List");
                }
            }

            city.ID = model.ID;
            city.Name = model.Name;
            city.PostCode = model.PostCode;
            city.CountryID = model.CountryID;

            citiesService.Save(city);

            return RedirectToAction("List");
        }
Exemple #30
0
        static void Main(string[] args)
        {
            /*
             * string fileName = @"C:\Users\lisse\Pictures\google_logo.svg";
             * byte[] file = System.IO.File.ReadAllBytes(fileName);
             * System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
             * Console.WriteLine(fileInfo.Length);
             */

            // Console.WriteLine(string.Join("", file));

            // AddressRepository aRepo = new AddressRepository();
            // Address address = aRepo.Get(1);

            /*
             * FilesRepository fileRepo = new FilesRepository();
             * Console.WriteLine(fileRepo.Get(1).FileName);
             * Files fileWrite = fileRepo.Get(2);
             * System.IO.File.WriteAllBytes(Path.Combine(@"C:\Users\lisse\Pictures\", fileWrite.FileName + "2"), fileWrite.FileByte);
             */

            /*
             * string fileName2 = @"C:\Users\lisse\Pictures\google_logo2.svg";
             * System.IO.FileInfo fileInfo2 = new System.IO.FileInfo(fileName2);
             * Files fileTest2 = new Files();
             * fileTest2.Name = "test import";
             * fileTest2.FileName = fileInfo2.Name;
             * fileTest2.FileExension = fileInfo2.Extension;
             * fileTest2.FileByte = System.IO.File.ReadAllBytes(fileName2);
             * fileTest2.FileSize = fileInfo2.Length;
             * fileTest2.CreateBy = 1;
             * Console.WriteLine(fileRepo.Insert(fileTest2));
             */

            /*
             * string projectDirectory = @"C:\Users\lisse\Documents\Technofuturtic\Projet";
             * string projectFilename = Path.Combine(projectDirectory, "ProjectFile.svg");
             * string productFilename = Path.Combine(projectDirectory, "ProductFile.svg");
             * byte[] projectByte = System.IO.File.ReadAllBytes(projectFilename);
             * byte[] productByte = System.IO.File.ReadAllBytes(productFilename);
             * string projectString = string.Empty;
             * string productString = string.Empty;
             *
             * foreach (byte b in projectByte)
             * {
             *  projectString = string.Concat(projectString, b.ToString());
             *  //Console.WriteLine(b.ToString());
             * }
             *
             * foreach (byte b in productByte)
             * {
             *  productString = string.Concat(productString, b.ToString());
             *  //Console.WriteLine(b.ToString());
             * }
             *
             * Console.WriteLine(projectString);
             */

            /*
             * // ************ City ***********
             * CitiesRepository cityR = new CitiesRepository();
             * Cities cityId = cityR.Get(1);
             * IEnumerable<Cities> cityByName = cityR.GetByName("lou");
             * IEnumerable<Cities> cityByPostalCode = cityR.GetByPostalCode("7110");
             * IEnumerable<Cities> cityByCountry = cityR.GetCityByCountry(21);
             */

            /*
             * // ************ Role ***********
             * RoleRepository roleR = new RoleRepository();
             * Roles role = roleR.Get(1);
             */

            /*
             * // ************ Account ***********
             * AccountRepository accR = new AccountRepository();
             * Account account = accR.Get(1);
             * Account account1 = accR.GetAccountByLogin("dave");
             * Account account2 = accR.GetAccountByLogin("davde");
             */


            /*
             * // ************ Supplier ***********
             * SupplierRepository suppR = new SupplierRepository();
             * Supplier supplier = suppR.Get(1);
             */

            /*
             * // ************ Project ***********
             * ProjectRepository projectR = new ProjectRepository();
             * Project project = projectR.Get(1);
             * IEnumerable<Project> projectAccount = projectR.GetProjectByAccountId(1);
             * IEnumerable<Project> projectByName = projectR.GetProjectByName("maison");
             */

            /*
             * // ************ Category ***********
             * CategoryRepository catR = new CategoryRepository();
             * Category cat = catR.Get(1);
             */


            // ************ ContactInfo ***********
            ContactInfoRepository ciR = new ContactInfoRepository();
            ContactInfo           ci  = ciR.Get(1);


            /*
             * // ************ Product ***********
             * ProductRepository productR = new ProductRepository();
             * Product p1 = productR.Get(1);
             * IEnumerable<Product> p2 = productR.GetAll();
             * IEnumerable<Product> p3 = productR.GetByManufacturer("Buderus");
             * IEnumerable<Product> p4 = productR.GetByName("Chaudière");
             */

            // ************ ProductCategory ***********
            ProductCategoryRepository     pdcR = new ProductCategoryRepository();
            IEnumerable <ProductCategory> pdc1 = pdcR.Get(1);

            // ************ ProjectCategory ***********
            ProjectCategoryRepository     pjcR = new ProjectCategoryRepository();
            IEnumerable <ProjectCategory> pjc1 = pjcR.Get(1);

            CountryService     countryService     = new CountryService();
            CitiesService      citiesService      = new CitiesService(countryService);
            AddressService     addressService     = new AddressService(citiesService);
            RolesService       rolesService       = new RolesService();
            ContactInfoService contactInfoService = new ContactInfoService();

            AccountService accServ = new AccountService(addressService, rolesService, contactInfoService);

            Console.WriteLine(accServ.Get(1).Address.Street);

            SupplierService supplierService = new SupplierService(addressService, contactInfoService);

            BLL.Models.Supplier supplier = supplierService.Get(1);

            FilesService filesService = new FilesService();

            BLL.Models.Files file = filesService.Get(1);

            CategoryService categoryService = new CategoryService();

            ProductCategoryService            productCategoryService = new ProductCategoryService(categoryService, filesService);
            List <BLL.Models.ProductCategory> productCategory        = productCategoryService.Get(1);

            ProductService productService = new ProductService(productCategoryService);

            ProjectCategoryProductService projectCategoryProductService = new ProjectCategoryProductService(productService, supplierService);

            ProjectCategoryService projectCategoryService = new ProjectCategoryService(categoryService, filesService, projectCategoryProductService);

            ProjectService projectService = new ProjectService(addressService, projectCategoryService);

            BLL.Models.Project project = projectService.Get(1);

            FilesRepository filesRepository = new FilesRepository();

            byte[] fileByte = filesRepository.Download(1);
        }
 public CitiesController(ICountryService countryService)
 {
     _citiesService = new CitiesService(countryService);
 }
Exemple #32
0
 public CitiesController(CitiesService elasticSearchService)
 {
     _elasticSearchService = elasticSearchService;
 }
Exemple #33
0
 public ServicesManager(DataManager dataManager)
 {
     _dataManager   = dataManager;
     _ordersServise = new OrdersService(dataManager);
     _citiesServise = new CitiesService(dataManager);
 }
        public ActionResult List()
        {
            CitiesService citiesService = new CitiesService();

            CitiesListVM model = new CitiesListVM();
            TryUpdateModel(model);

            model.Cities = citiesService.GetAll();

            if (!String.IsNullOrEmpty(model.Search))
            {
                model.Cities = model.Cities.Where(c => c.Name.ToLower().Contains(model.Search.ToLower())).ToList();
            }

            switch (model.SortOrder)
            {
                case "country_asc":
                    model.Cities = model.Cities.OrderBy(c => c.Country.Name).ToList();
                    break;
                case "country_desc":
                    model.Cities = model.Cities.OrderByDescending(c => c.Country.Name).ToList();
                    break;
                case "postcode_asc":
                    model.Cities = model.Cities.OrderBy(c => c.PostCode).ToList();
                    break;
                case "postcode_desc":
                    model.Cities = model.Cities.OrderByDescending(c => c.PostCode).ToList();
                    break;
                case "name_desc":
                    model.Cities = model.Cities.OrderByDescending(c => c.Name).ToList();
                    break;
                case "name_asc":
                default:
                    model.Cities = model.Cities.OrderBy(c => c.Name).ToList();
                    break;
            }

            return View(model);
        }