/// <summary>
        /// 删除City信息
        /// </summary>
        /// <param name="ids">要删除的Id编号</param>
        /// <returns>业务操作结果</returns>
        public async Task <OperationResult> DeleteCitys(params int[] ids)
        {
            ids.CheckNotNull("ids");
            await CityRepo.RecycleAsync(p => ids.Contains(p.Id));

            return(new OperationResult(OperationResultType.Success, "删除成功"));
        }
Esempio n. 2
0
 public UnitOfWork(DataContext context)
 {
     this.context = context;
     cityRepo = new CityRepo(context);
     countryRepo = new CountryRepo(context);
     continentRepo = new ContinentRepo(context);
     riverRepo = new RiverRepo(context);
     
 }
        public void StoreDataWeatherStaticsTest()
        {
            MongoDbUtil.Instance().Drop();
            WeatherSevice sevice = new WeatherSevice();

            sevice.StoreDataWeather(CityRepo.Cities().Take(5).ToList(), "BE");
            sevice.GetWeatherStatics();
            Assert.IsTrue(sevice.GetWeatherStatics().AllWeatherDatas().Count() == 4);
        }
Esempio n. 4
0
        public void GetWeatherBulkNowTest()
        {
            WeatherWebRetrieverService webRetrieverService = new WeatherWebRetrieverService();

            WeatherStatics statics = webRetrieverService.GetWeatherBulkNow(CityRepo.Cities().Take(5).ToList(), "BE");

            //      statics.CreateReport();
            Assert.AreEqual(4, statics.AllWeatherDatas().Count);
        }
Esempio n. 5
0
        public EnquiryController()
        {
            _pRepo = new PackageRepo();

            _hRepo = new HotelRepo();

            _enqRepo = new EnquiryRepo();

            _cRepo = new CityRepo();
        }
Esempio n. 6
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context        = context;
     Patients        = new PatientRepo(context);
     Appointments    = new AppointmentRepo(context);
     Attandences     = new AttendanceRepo(context);
     Cities          = new CityRepo(context);
     Doctors         = new DoctorRepo(context);
     Specializations = new SpecializationRepo(context);
     Users           = new ApplicationUserRepo(context);
 }
Esempio n. 7
0
 /// <summary>
 /// Obtener cantidad de registros de Sancion
 /// Autor: Jair Guerrero
 /// Fecha: 2020-08-06
 /// </summary>
 public int Count()
 {
     try
     {
         IRepository <City> repo = new CityRepo(context);
         return(repo.Count());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Esempio n. 8
0
 public EntityService()
 {
     _appointmentService = new AppointmentRepo();
     _cityService        = new CityRepo();
     _hospitalService    = new HospitalRepo();
     _patientRepo        = new PatientRepo();
     _policlinicService  = new PoliclinicRepo();
     _staffRepo          = new StaffRepo();
     _titleService       = new TitleRepo();
     _townService        = new TownRepo();
     _userService        = new UserRepo();
 }
Esempio n. 9
0
        public void TestMethod1()
        {
            // https://docs.microsoft.com/en-us/ef/ef6/fundamentals/testing/mocking?redirectedfrom=MSDN

            IQueryable <City> ciudades = new List <City>
            {
                new City {
                    city_id = 1, city1 = "Chile"
                },
                new City {
                    city_id = 2, city1 = "Argentina"
                },
                new City {
                    city_id = 3, city1 = "Peru"
                },
            }.AsQueryable();

            var mockCiudades = new Mock <DbSet <City> >();

            // placeholder
            mockCiudades.As <IQueryable <City> >()
            .Setup(m => m.Provider).Returns(ciudades.Provider);
            mockCiudades.As <IQueryable <City> >()
            .Setup(m => m.Expression).Returns(ciudades.Expression);
            mockCiudades.As <IQueryable <City> >()
            .Setup(m => m.ElementType).Returns(ciudades.ElementType);
            mockCiudades.As <IQueryable <City> >()
            .Setup(m => m.GetEnumerator()).Returns(ciudades.GetEnumerator());

            var mockSakila = new Mock <SakilaContexto>();

            mockSakila.Setup(c => c.city).Returns(mockCiudades.Object);

            var repo = new CityRepo(mockSakila.Object);

            Assert.AreEqual(3, repo.ListarTodo().Count);


            var ciudadNueva = new City {
                city_id = 4, city1 = "Canada"
            };

            Assert.AreEqual(4, repo.Insertar(ciudadNueva));

            Assert.AreEqual("Canada", repo.Obtener(4).city1);



            //string[] paises=new string[3] {"Chile","Argentina","Peru"};
            //IEnumerable<string> pais =paises.Where(p=>p=="Chile");
            //var listado=pais.ToList();
        }
Esempio n. 10
0
 public CommonController()
 {
     _cityRepo              = new CityRepo();
     _countyRepo            = new CountyRepo();
     _transfusionCenterRepo = new TransfusionCenterRepo();
     _requestRepo           = new RequestRepo();
     _profileRepo           = new ProfileRepo();
     _appointmentService    = new DonationAppointmentService(new DonationAppointmentRepo());
     _bloodTypeService      = new BloodTypeService(new BloodTypeRepo());
     _notificationService   = new NotificationService();
     _labResultService      = new LabResultService(new LabResultRepo());
     _donationService       = new DonationService(new DonationRepo());
 }
Esempio n. 11
0
        /// <summary>
        /// Crear registro de Sancion
        /// Autor: Jair Guerrero
        /// Fecha: 2020-08-06
        /// </summary>
        public long Create(CityAM entity)
        {
            try
            {
                var sancion = mapper.Map <City>(entity);

                IRepository <City> repo = new CityRepo(context);
                return(repo.Create(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Obtener Sancion por Id
        /// Autor: Jair Guerrero
        /// Fecha: 2020-08-06
        /// </summary>
        public CityAM Get(long id)
        {
            try
            {
                IRepository <City> repo = new CityRepo(context);
                var sancion             = repo.Get(id);

                return(mapper.Map <CityAM>(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Obtener cantidad de registros de Sancion según filtro
        /// Autor: Jair Guerrero
        /// Fecha: 2020-08-06
        /// </summary>
        public int Count(Expression <Func <CityAM, bool> > predicate)
        {
            try
            {
                var where = mapper.MapExpression <Expression <Func <City, bool> > >(predicate);

                IRepository <City> repo = new CityRepo(context);
                return(repo.Count(where));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Esempio n. 14
0
        public void AddBulkTest()
        {
            WeatherStatics weatherStatics = new WeatherStatics();

            foreach (var city in CityRepo.Cities().Take(5))
            {
                Current current = RestWeatherForcastUtil.GetDataFromUrlByZipCode(city, "BE").Result;
                if (current != null)
                {
                    weatherStatics.Add(new WeatherData(current));
                }
            }

            Assert.AreEqual(4, weatherStatics.AllWeatherDatas().Count);
        }
Esempio n. 15
0
        private void GetOne()
        {
            City city = new City();

            city.CityId = int.Parse(Helper.GetParameterFromRequest("cityId"));
            CityRepo Repo = new CityRepo(city);

            if (Repo.Query())
            {
                Helper.Response(city.Serialize());
            }
            else
            {
                Helper.ResponseError(Repo.ErrorMessage);
            }
        }
Esempio n. 16
0
        public async Task SeedAsync(DataSeedContext context)
        {
            var provinceE = new ProvinceEntity("Western");
            var districtE = new DistrictEntity("Colombo", provinceE.Id);
            var cityE     = new CityEntity(districtE.Id)
            {
                CityName    = "Delkanda",
                Geolocation = "6.784568:79.546545"
            };

            await ProvinceRepo.InsertAsync(provinceE);

            await DistrictRepo.InsertAsync(districtE);

            await CityRepo.InsertAsync(cityE);
        }
Esempio n. 17
0
        /// <summary>
        /// Obtener primera Sancion según filtro
        /// Autor: Jair Guerrero
        /// Fecha: 2020-08-06
        /// </summary>
        public CityAM GetFirst(Expression <Func <CityAM, bool> > predicate)
        {
            try
            {
                var where = mapper.MapExpression <Expression <Func <City, bool> > >(predicate);

                IRepository <City> repo = new CityRepo(context);
                var sancion             = repo.GetFirst(where);

                return(mapper.Map <CityAM>(sancion));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Esempio n. 18
0
        public async void GetCityByIdTest()
        {
            //Arrange
            IList <CityModel> cities = GenerateCities();
            var travelAPIContextMock = new Mock <TravelAPIContext>();

            travelAPIContextMock.Setup(c => c.Cities).ReturnsDbSet(cities);

            var logger           = Mock.Of <ILogger <CityRepo> >();
            var citiesRepository = new CityRepo(travelAPIContextMock.Object, logger);
            //Act
            var theCity = await citiesRepository.GetCityById(1);

            //Assert
            Assert.Equal(1, theCity.CityId);
        }
Esempio n. 19
0
        public async void GetCityPopulationByName(string inlineName, int expected)
        {
            //Arrange
            IList <CityModel> cities = GenerateCities();
            var travelAPIContextMock = new Mock <TravelAPIContext>();

            travelAPIContextMock.Setup(c => c.Cities).ReturnsDbSet(cities);

            var logger           = Mock.Of <ILogger <CityRepo> >();
            var citiesRepository = new CityRepo(travelAPIContextMock.Object, logger);

            //Act
            var theCity = await citiesRepository.GetCityByName(inlineName);

            //Assert
            Assert.Equal(expected, theCity.Population);
        }
Esempio n. 20
0
        public UnitOfWork(GoldStreamerContext e, bool DropDB = false)
        {
            if (DropDB)
            {
                DropDatabase(e);
            }
            if (e != null)
            {
                entities = e;
            }
            else
            {
                entities = new GoldStreamerContext();
            }

            TraderRepo            = new TraderRepo <Trader>(this.entities);
            TradePricesRepo       = new TraderPricesRepo <TraderPrices>(this.entities);
            PriceViewerRepo       = new PricerRepo <Prices>(this.entities);
            BasketRepo            = new BasketRepo <Basket>(this.entities);
            BasketPricesRepo      = new BasketPricesRepo <BasketPrices>(this.entities);
            BasketTradersRepo     = new BasketTradersRepo <BasketTraders>(this.entities);
            TraderFavRepo         = new TraderFavRepo <TraderFavorites>(this.entities);
            FavorateListRepo      = new FavoriteListRepo <FavoriteList>(this.entities);
            UsersRepo             = new UsersRepo <Users>(this.entities);
            GovernorateRepo       = new GovernorateRepo(this.entities);
            CityRepo              = new CityRepo(this.entities);
            RegionRepo            = new RegionRepo(this.entities);
            RolePermissionRepo    = new RolePermissionRepo <RolePermission>(this.entities);
            FeedbackRepo          = new FeedbackRepo <Feedback>(this.entities);
            QuestionGroupRepo     = new QuestionGroupRepo <QuestionGroup>(this.entities);
            QuestionRepo          = new QuestionRepo <Question>(this.entities);
            SubscribeRepo         = new SubscribeRepo <Subscribe>(this.entities);
            NewsMainCategoryRepo  = new NewsMainCategoryRepo <NewsMainCategory>(this.entities);
            NewsCategoryRepo      = new NewsCategoryRepo <NewsCategory>(this.entities);
            NewsRepo              = new NewsRepo <News>(this.entities);
            GlobalPriceRepo       = new GlobalPriceRepo <GlobalPrice>(entities);
            TraderPricesChartRepo = new TraderPricesChartRepo <TraderPricesChart>(entities);
            DollarRepo            = new DollarRepo <Dollar>(entities);
        }
Esempio n. 21
0
        /// <summary>
        /// 保存City信息(新增/更新)
        /// </summary>
        /// <param name="updateForeignKey">更新时是否更新外键信息</param>
        /// <param name="dtos">要保存的CityDto信息</param>
        /// <returns>业务操作集合</returns>
        public async Task <OperationResult> SaveCitys(bool updateForeignKey = false, params CityDto[] dtos)
        {
            try
            {
                dtos.CheckNotNull("dtos");
                var addDtos    = dtos.Where(p => p.Id == 0).ToArray();
                var updateDtos = dtos.Where(p => p.Id != 0).ToArray();

                CityRepo.UnitOfWork.TransactionEnabled = true;

                Action <CityDto>           checkAction = null;
                Func <CityDto, City, City> updateFunc  = (dto, entity) =>
                {
                    if (dto.Id == 0 || updateForeignKey)
                    {
                        entity.Province = ProvinceRepo.GetByKey(dto.ProvinceId);
                    }
                    return(entity);
                };
                if (addDtos.Length > 0)
                {
                    CityRepo.Insert(addDtos, checkAction, updateFunc);
                }
                if (updateDtos.Length > 0)
                {
                    CityRepo.Update(updateDtos, checkAction, updateFunc);
                }
                await CityRepo.UnitOfWork.SaveChangesAsync();

                return(new OperationResult(OperationResultType.Success, "保存成功"));
            }
            catch (Exception e)
            {
                return(new OperationResult(OperationResultType.Error, e.Message));
            }
        }
        public SupplierSearchController()
        {
            _ssRepo = new SupplierSearchRepo();

            _cRepo = new CityRepo();
        }
Esempio n. 23
0
 public CompanyManager()
 {
     _CompanyRepo = new CompanyRepo();
     _CityRepo    = new CityRepo();
 }
 public void CitiesTest()
 {
     Assert.IsNotNull(CityRepo.Cities().Count > 5);
     Assert.IsNotNull(CityRepo.Cities().Contains("9880"));
 }
Esempio n. 25
0
 public CityManager()
 {
     _cityRepo    = new CityRepo();
     _stateRepo   = new StateRepo();
     _countryRepo = new CountryRepo();
 }
Esempio n. 26
0
 public CityController()
 {
     _cRepo = new CityRepo();
 }