public City(int CityID) { this.cityID = CityID; CityService cs = new CityService(); this.cityName = cs.GetCityByID(CityID); this.centerID = cs.GetCenterIDByCityID(CityID); }
public void PopulateCitiesGridView() { CityService cs = new CityService(); DataSet ds = cs.GetCitiesAndCenters(); this.GridView1.DataSource = ds; this.GridView1.DataBind(); }
public CityServiceTest() { _cityRepositoryMock = new Mock <ICityRepository>(); _mapperMock = new Mock <IMapper>(); _apiExternalWeatherMapsMock = new Mock <IApiExternalWeatherMaps>(); _cityService = new CityService(_cityRepositoryMock.Object, _mapperMock.Object, _apiExternalWeatherMapsMock.Object); }
public ActionResult Edit(string cityId) { this.ViewBag.Status = new SelectList(this.GetStatus(), "Key", "Value"); ICityService svc = new CityService(); var model = svc.Getdata(cityId); return(View("~/Views/Master/City/Edit.cshtml", model)); }
public void PopulateDestinationCitiesDropDown() { CityService cs = new CityService(); this.DropDownListDestinationCities.DataSource = cs.GetAllCities(); this.DropDownListDestinationCities.DataTextField = "CityName"; this.DropDownListDestinationCities.DataValueField = "CenterID"; this.DropDownListDestinationCities.DataBind(); }
private ICityService getCityService() { DbContextOptions options = MySqlDbContextOptionsExtensions.UseMySql(new DbContextOptionsBuilder(), ConnectionString).Options; SakilaDbContext ctx = new SakilaDbContext(options); ICityService cityService = new CityService(ctx); return(cityService); }
public void Throws_InvalidClientInputException_WhenCityNameIsNotCorrect(string cityName) { var mockContext = new Mock <AlphaCinemaContext>(); var cityService = new CityService(mockContext.Object); Assert.ThrowsExceptionAsync <InvalidClientInputException>(() => cityService.AddCity(cityName)); }
public async Task GetAllTest() { CityService cityService = CreateCityService(); var result = await cityService.GetAllAsync(); Assert.NotNull(result); }
public async Task OnRemoveCityAsyncWithInvalidKey() { CityRepository.GetByKeyAsync(Arg.Any <Guid>()).Returns(Task.FromResult <City>(null)); var result = await CityService.RemoveAsync(Guid.NewGuid()); result.Success.Should().BeFalse(); }
public TalkController(TalkService talkService, SpeakerService speakerService, CityService cityService, PlaceService placeService, AuthenticationProvider authenticationProvider) { _talkService = talkService; _speakerService = speakerService; _cityService = cityService; _placeService = placeService; _authenticationProvider = authenticationProvider; }
public CityServiceTests() { context = new TestingContext(); service = new CityService(new UnitOfWork(context)); context.DropData(); SetUpData(); }
public CadastroVoluntario() { InitializeComponent(); ConfigurarCombobox(); voluntaryService = new VoluntaryService(); cityService = new CityService(); functionService = new FunctionService(); }
public void SetUp() { CityRepository = Substitute.For <ICityRepository>(); PostalCodeService = Substitute.For <IPostalCodeService>(); WeatherService = Substitute.For <IWeatherService>(); CityTemperatureRepository = Substitute.For <ICityTemperatureRepository>(); CityService = new CityService(PostalCodeService, CityRepository, WeatherService, CityTemperatureRepository); }
public void Setup() { _cities = _dataSeed.GetCities(); _cityMock = DbContextMock.GetQueryableMockDbSet(_cities); _mock.Setup(c => c.Cities).Returns(_cityMock.Object); _cityService = new CityService(_mock.Object); }
public void Constructor_Should_CreateCityServices_IfParamsAreValid() { // Arrange & Act var mockedDbSet = new Mock <IEfCarSystemDbSetCocoon <City> >(); var cityService = new CityService(mockedDbSet.Object); // Assert Assert.That(cityService, Is.InstanceOf <CityService>()); }
public async Task OnGetAllAsyncWithMoreThanMaxPerPage() { var paging = new PagingDto { RecordsPerPage = Faker.RandomNumber.Next(101, 1000) }; var result = await CityService.GetAllAsync(paging); result.Success.Should().BeFalse(); }
public CityServiceTest() { _repository = new Mock <ICityRepository>(); _service = new CityService(_repository.Object); city = new City() { Name = "test", Population = 1000, Id = "a" }; }
public ActionResult ViewCity(int id) { if (id > 0) { var model = new CityService().GetCity(id); return(View(model)); } return(View()); }
private void BindGrid() { grdUser.DataSource = CityService.CityInfo_GetByAll(); grdUser.DataBind(); if (grdUser.PageCount <= 1) { grdUser.PagerStyle.Visible = false; } }
public async Task <IHttpActionResult> PutCity(int id, CityPutDto city) { if (id != city.Id) { CustomException.ThrowBadRequestException($"Id: {id} doesn't match."); } return(Ok(await CityService.Update(city))); }
public AdvertisementController() { _appUserService = new AppUserService(); _cityService = new CityService(); _districtService = new DistrictService(); _pettypeService = new PettypeService(); _raceService = new RaceService(); _advertisementService = new AdvertisementService(); }
public async Task GetByIdTest() { CityService cityService = CreateCityService(); var result = await cityService.GetByIdAsync(GetIdForSearch); Assert.NotNull(result); Assert.IsType <CityDTO>(result); }
public void GetAllCities_Should_NotBeCalled_IfItIsNeverCalled() { // Arrange & Act var mockedDbSet = new Mock <IEfCarSystemDbSetCocoon <City> >(); var cityService = new CityService(mockedDbSet.Object); // Assert mockedDbSet.Verify(rep => rep.All(), Times.Never); }
public void GetById_Should_NotBeCalled_IfNotCalledYolo() { // Arrange & Act var mockedDbSet = new Mock <IEfCarSystemDbSetCocoon <City> >(); var cityService = new CityService(mockedDbSet.Object); // Assert mockedDbSet.Verify(rep => rep.GetById(1), Times.Never); }
public void Test1() { string cityName = DateTime.Now.ToFileTimeUtc().ToString(); CityService citySvc = new CityService(); long cityId = citySvc.AddNew(cityName); Assert.AreEqual(citySvc.GetById(cityId).Name, cityName); citySvc.GetAll(); }
public async Task CityProfileTest() { CityService cityService = CreateCityService(); var result = await cityService.GetCityProfileAsync(GetIdForSearch); Assert.NotNull(result); Assert.IsType <CityProfileDTO>(result); }
private void CityComboBoxList() //Column 3 { var Cit = CityService.GetCity().Select(x => x.Name); foreach (var cit in Cit) { CityComboBox.Items.Add(cit); } }
static void Main(string[] args) { AssemblyMaster am = new AssemblyMaster(); #region CS am.CityServices_URL = @"SmartCity_Services.xml"; CityService cs = new CityService(); cs.Service_Code = 102; cs.Service_Name = "Police"; am.Create_City_Service(cs); #endregion #region City am.Cities_URL = @"SmartCity_Cities.xml"; City city = new City(); city.City_Area = 300629; city.City_Population = 834813; city.City_Name = "Актобе"; city.City_Services = new List <CityService>() { cs }; am.Create_City(city); #endregion #region Region am.Regions_URL = @"SmartCity_Region.xml"; Region region = new Region(); region.Main_City = city; region.Population = 834813; region.Cities = null; region.Region_Name = "Актюбинская область"; am.Create_Region(region); #endregion #region Police station Master_Police mp = new Master_Police(); mp.Police_Station_URL = @"Police_Station.xml"; Police_Station ps = new Police_Station(); ps.Police_Station_Adress = "Тимирязева 31"; ps.city = am.GetCity()[0]; ps.Police_Station_ID = 001; ps.Police_Station_Name = "Тимимрязева"; mp.Create_Police_Station(ps); #endregion #region #endregion }
public string GetCityName(int id) { var item = CityService.GetById(id); if (item != null) { return(item.Name); } return(""); }
public ActionResult CashInfo(decimal orderId) { CartService.SetPaymentType(PaymentTypes.Cash, orderId); var cities = CityService.GetAll().Where(x => x.City_TC == Cities.Moscow) .OrderBy(c => c.SortOrder); ViewData["Manager"] = GetSiteManager(orderId); return(MView(Views.Order.CashInfo, cities)); }
private void CityComboBoxList() //Column 3 { CityComboBox.Items.Clear(); var Cit = CityService.GetCity().Where(x => x.CountryModel.Id == Id_Country).Select(x => x.Name); foreach (var cit in Cit) { CityComboBox.Items.Add(cit); } }
public ActionResult DeleteCity(int id) { var service = new CityService(); service.DeleteCity(id); TempData["SaveResult"] = "The city was deleted."; return(RedirectToAction("Index")); }
private void CityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { CitySetName.Text = CityService.GetCity() .Where(x => (x.Name == CityComboBox.SelectedItem.ToString())) .Select(x => x.Name).FirstOrDefault().ToString(); CitySetPopulation.Text = CityService.GetCity() .Where(x => (x.Name == CityComboBox.SelectedItem.ToString())) .Select(x => x.Population).FirstOrDefault().ToString(); }
protected void ButtonSubmit_Click(object sender, EventArgs e) { //השגת הנתונים לגבי המשתמש int clientID = Convert.ToInt32(Session["UserID"]); Client orderingClient = new Client(clientID); City collectingCity = new City(orderingClient.GetCityID()); string collectingCityName = collectingCity.GetCityName(); int collectingCityID = orderingClient.GetCityID(); string collectingAddress = orderingClient.GetAddress(); string date = DateTime.Now.ToShortDateString(); string item = this.TextBoxItemDescription.Text; string itemWeight = this.TextBoxItemWeight.Text; int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities.SelectedValue); string destinationCityName = this.DropDownListDestinationCities.SelectedItem.ToString(); string destinationAddress = this.TextBoxAddress.Text; string destinationDate = DateTime.Now.AddDays(30).ToShortDateString(); //חישוב המחיר CityService cs=new CityService(); int collectingCenterID = collectingCity.GetCenterID(); int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID); int temp = destinationCenterID - collectingCenterID; if (temp < 0) temp *= -1; temp += 1; double price; price= 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10); if (this.CheckBoxUrgent.Checked) { price += 10; } if (price < 20) price = 20; int roundedPrice = Convert.ToInt32(price); try { string sqlCommand = "INSERT INTO Orders (CollectingCityID,CollectingCityName,CollectingAddress,OrderingDate,DestinationCityID,DestinationCityName,DestinationAddress,DestinationDate,Item,ItemWeight,WorkerID,ClientID,Price,Status) VALUES (" + collectingCityID + ",'" + collectingCityName + "','" + collectingAddress + "','" + date + "'," + destinationCityID + ",'" + destinationCityName + "','" + destinationAddress + "','" + destinationDate + "','" + item + "'," + itemWeight + ",0," + clientID + "," + roundedPrice + ",'New');"; OleDbConnection myCon = new OleDbConnection(Connect.getConnectionString()); OleDbCommand cmd = new OleDbCommand(sqlCommand, myCon); myCon.Open(); cmd.ExecuteNonQuery(); myCon.Close(); Response.Redirect("HomePage.aspx"); } catch (Exception ex) { throw ex; } }
protected void ButtonSend_Click(object sender, EventArgs e) { if (this.CheckBoxAgreement.Checked) { string ID = this.TextBoxID.Text; string userName = this.TextBoxUserName.Text; string pass = this.TextBoxPass.Text; string passVerification = this.TextBoxPass2.Text; string email = this.TextBoxEmail.Text; string phone = this.DropDownList1.SelectedItem + this.TextBoxPhone.Text; string city = this.DropDownListCities.Text; string address = this.TextBoxAddress.Text; int cityID = Convert.ToInt32(this.DropDownListCities.SelectedValue); string fName = this.TextBoxFirstName.Text; string lName = this.TextBoxLastName.Text; City userCity = new City(); userCity.SetCityID(cityID); userCity.SetCityName(city); CityService cs = new CityService(); userCity.SetCenterID(cs.GetCenterIDByCityID(cityID)); OleDbConnection myCon = new OleDbConnection(Connect.getConnectionString()); OleDbCommand cmd = new OleDbCommand("SELECT * FROM Clients WHERE UserName='******';", myCon); myCon.Open(); if (cmd.ExecuteScalar() == null) { string sqlCommand = "INSERT INTO Clients (CityID,UserName,Pass,Phone,Email,Address,FirstName,LastName,ID,Activity) VALUES(" + cityID + ",'" + userName + "','" + pass + "','" + phone + "','" + email + "','" + address + "','" + fName + "','" + lName + "','"+ID+"','UnActive');"; cmd.CommandText = sqlCommand; cmd.ExecuteNonQuery(); } myCon.Close(); } else { Response.Write("<script type=\"text/javascript\">alert('אנא אשר את תנאי האתר')</script>"); } }
public List<City> GetCityState() { CityService cs=new CityService(); List<City> cityList = cs.GetAll(); City[] vexs = cityList.ToArray(); EData[] edges = cs.GetAllRelation(); // 采用已有的"图" var pG = new ListUdg(vexs, edges); int[] prev = new int[pG.MVexs.Length]; int[] dist = new int[pG.MVexs.Length]; pG.Dijkstra(vexs.ToList().FindIndex(x => x.Name == "洛阳"), prev, dist); foreach (var city in cityList) { if (city.X != 0 && city.Y != 0) { string color=_dm.GetColor(city.X,city.Y); if (color == "ee4814") city.BelongTo=BelongTo.蜀国城池; else if (color == "1da5f1") city.BelongTo=BelongTo.魏国城池; else if (color == "5ad543") city.BelongTo=BelongTo.吴国城池; else city.BelongTo = BelongTo.无法识别; city.State = State.未识别; int index = vexs.ToList().FindIndex(x => x.Name == city.Name); city.Distance = dist[index]; city.PrevCity = prev[index] == 0 ? null : vexs[prev[index]]; } } #region 输出城池归属 //var aa = cityList.Where(c => c.X != 0).Where(x => x.BelongTo == BelongTo.魏国城池).ToList(); //var bb = cityList.Where(c => c.X != 0).Where(x => x.BelongTo == BelongTo.吴国城池).ToList(); //var ccd = cityList.Where(c => c.X != 0).Where(x => x.BelongTo == BelongTo.蜀国城池).ToList(); //Debug.WriteLine("魏国城池:"); //foreach (var city3 in aa) //{ // Debug.Write(city3.Name + "|"); //} //Debug.WriteLine(""); //Debug.WriteLine("吴国城池:"); //foreach (var city1 in bb) //{ // Debug.Write(city1.Name + "|"); //} //Debug.WriteLine(""); //Debug.WriteLine("蜀国城池"); //foreach (var city2 in ccd) //{ // Debug.Write(city2.Name + "|"); //} //Debug.WriteLine(""); #endregion // _dm.Delay(1000); return cityList; }
public ActionResult ViewUser() { RequireLogin(); UserViewModel model = new UserViewModel { UserEntity = UserInfo }; try { CityService cityService = new CityService(); model.Provinces = cityService.GetProvinces(true); if (!string.IsNullOrEmpty(model.UserEntity.LocationId)) { model.Cities = cityService.GetCitiesByProvinceId(model.UserEntity.Province, true); //市 model.Areas = cityService.GetAreasByCityId(model.UserEntity.City, true); //区 } } catch (Exception e) { LogService.Log("用户中心-index", e.ToString()); } return View(model); }
public static void UpdateCities() { CityService cityService = new CityService(); _allCities = cityService.GetCities(true); }
private TaskResult Step2(TaskContext arg) { Role role = (Role)arg.Role; DmPlugin dm = role.Window.Dm; role.CloseBoard(); role.CloseMenu(); City city=new CityService().GetAll().FirstOrDefault(x => x.Name == DstCityName); if(city==null) return new TaskResult(TaskResultType.Failure, "目标城市不存在"); Delegater.WaitTrue(() => role.HasMapOpen(), () => dm.MoveToClick(1222, 94)); var b=role.GetCityBelong(city.X,city.Y); if(b==BelongTo.魏国城池||b==BelongTo.无法识别) return new TaskResult(TaskResultType.Failure, "城池不属于敌方或无法识别"); //点击地图上的城池坐标 if (city.X == 0 || city.Y == 0) return new TaskResult(TaskResultType.Failure, "城市坐标没有更新"); dm.MoveToClick(city.X, city.Y); dm.Delay(100); //关闭地图 Delegater.WaitTrue(() => !role.HasMapOpen(), () => dm.MoveToClick(1222, 94)); //点击屏幕城池的坐标 bool ret = Delegater.WaitTrue(() => dm.MoveToClick(611, 436)==1, () => dm.Delay(100), 2); if (!ret) { role.OutSubMessage("点击城市{0}失败".FormatWith(city.Name)); return new TaskResult(TaskResultType.Failure, "城市名称无法识别"); } dm.Delay(100); //召集张梁 // ret = role.ConveneGenerals("张梁"); Delegater.WaitTrue(() => role.HasPicExist(541, 305, 884, 540, "血战.bmp"), () => dm.Delay(1000), 3); dm.MoveToClick(764, 431); Delegater.WaitTrue(() => role.HasStrExist(470, 202, 755, 347, "血战", "dadada-303030"), () => dm.Delay(1000), 3); int intX, intY; dm.FindPic(367, 294, 919, 492, "张梁血战.bmp", "000000", 0.9, 0, out intX, out intY); if (intX < 0 && intY < 0) { return new TaskResult(TaskResultType.Failure, "无法找到张梁图片"); } if(Math.Abs(intX-441)>20) dm.MoveToClick(441, 363); if (Math.Abs(intX - 552) > 20) dm.MoveToClick(552, 363); if (Math.Abs(intX - 666) > 20) dm.MoveToClick(666, 363); if (Math.Abs(intX - 779) > 20) dm.MoveToClick(779, 363); dm.MoveToClick(636, 579); dm.Delay(1000); dm.MoveToClick(746, 574); dm.Delay(1000); dm.MoveToClick(60, 284); return TaskResult.Success; }
public int CalculatePrice(int num) { if (num == 1) { int clientID = Convert.ToInt32(Session["UserID"]); Client orderingClient = new Client(clientID); City collectingCity = new City(orderingClient.GetCityID()); string itemWeight = this.TextBoxItemWeight.Text; int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities.SelectedValue); //חישוב המחיר CityService cs = new CityService(); int collectingCenterID = collectingCity.GetCenterID(); int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID); int temp = destinationCenterID - collectingCenterID; if (temp < 0) temp *= -1; temp += 1; double price; price = 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10); if (this.CheckBoxUrgent.Checked) { price += 10; } if (price < 20) price = 20; int roundedPrice = Convert.ToInt32(price); return roundedPrice; } else if (num == 2) { int collectingCityID = Convert.ToInt32(this.DropDownListCollectingCities.SelectedValue); City collectingCity = new City(collectingCityID); string itemWeight = this.TextBoxItemWeight2.Text; int destinationCityID = Convert.ToInt32(this.DropDownListDestinationCities2.SelectedValue); //חישוב המחיר CityService cs = new CityService(); int collectingCenterID = collectingCity.GetCenterID(); int destinationCenterID = cs.GetCenterIDByCityID(destinationCityID); int temp = destinationCenterID - collectingCenterID; if (temp < 0) temp *= -1; temp += 1; double price; price = 5 * Math.Log(double.Parse(itemWeight)) + 10 + (temp * 10); if (this.CheckBoxUrgent2.Checked) { price += 10; } if (price < 20) price = 20; int roundedPrice = Convert.ToInt32(price); return roundedPrice; } else return 0; }
private void BtnSettingPoint_OnClick(object sender, RoutedEventArgs e) { CityService cs = new CityService(); List<City> cityList = cs.GetAll(); foreach (var city in cityList) { if (city.X == 0 || city.Y == 0) { this.LblCityName.Content = city.Name; break; } } }
public ActionResult ViewUser() { WeChatUserViewModel model = new WeChatUserViewModel { WeChatUserEntity = CurrentWeChatUser, UserEntity = CurrentUser }; try { if (!CurrentWeChatUser.IsUserLoggedIn) { return Redirect("/wechat/account/login"); } CityService cityService = new CityService(); model.Provinces = cityService.GetProvinces(true); if (!string.IsNullOrEmpty(model.UserEntity.LocationId)) { model.Cities = cityService.GetCitiesByProvinceId(model.UserEntity.Province, true); //市 model.Areas = cityService.GetAreasByCityId(model.UserEntity.City, true); //区 } } catch (Exception e) { LogService.Log("用户中心-viewuser", e.ToString()); } return View(model); }
public void PopulateCollectingCitiesDropDown() { CityService cs = new CityService(); this.DropDownListCollectingCities.DataSource = cs.GetCitiesAndCenters(); this.DropDownListCollectingCities.DataTextField = "CityName"; this.DropDownListCollectingCities.DataValueField = "CityID"; this.DropDownListCollectingCities.DataBind(); ListItem item = new ListItem("בחר עיר", "0"); this.DropDownListCollectingCities.Items.Add(item); this.DropDownListCollectingCities.SelectedValue = "0"; }