public void GetTopOneRegionChoosenByTheRegisteredUsersTest() { IUserService _userService = new UserService(_context); IActivityService _activityService = new ActivityService(_context); IRegionService _regionService = new RegionService(_context); IUserActivityService _userActivityService = new UserActivityService(_context); // Region Region bd = new Region { RegionName = "Bangladesh" }; Region usa = new Region { RegionName = "USA" }; Region canada = new Region { RegionName = "Canada" }; _regionService.AddRegion(bd); _regionService.AddRegion(usa); _regionService.AddRegion(canada); ApplicationUser test = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser alif = new ApplicationUser { UserName = "******", Region = usa }; ApplicationUser hamza = new ApplicationUser { UserName = "******", Region = canada }; ApplicationUser kabir = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser saif = new ApplicationUser { UserName = "******", Region = canada }; ApplicationUser salman = new ApplicationUser { UserName = "******", Region = bd }; _userService.AddUser(test); _userService.AddUser(alif); _userService.AddUser(hamza); _userService.AddUser(kabir); _userService.AddUser(saif); _userService.AddUser(salman); var topRegion = _userActivityService.GetTopFiveRegionChoosenByTheRegisteredUsers().FirstOrDefault(); Assert.IsNotNull(topRegion); Assert.AreEqual(bd.RegionName, topRegion.Region.RegionName); }
public ActionResult AddRegion(long cityId, string name) { try { RegionService.AddRegion(cityId, name); return(Json(new AjaxResult <Object> { code = 0, msg = "添加成功" })); } catch (Exception ex) { Log.ErrorFormat("添加小区失败:" + ex.Message); return(Json(new AjaxResult <Object> { code = 1, msg = ex.Message })); } }
protected void BtnAddRegion_Click(object sender, EventArgs e) { var region = new Region(); region.RegionName = RegionNamebox.Text.ToString().Trim(); var regionService = new RegionService(); int count = regionService.ExperimentalRegion(region); // if(DDLCountry.Text=="") if (DDLCountry.Text == "-请选择-") { Response.Write("<script>alert('请选择国家')</script>"); } else if (count <= 0) { region.CountryId = Convert.ToInt32(DDLCountry.SelectedValue);//get Id value if (!string.IsNullOrWhiteSpace(region.RegionName)) { var result = regionService.AddRegion(region); if (result == 1) { BindCountry(); Response.Write("<script>alert('添加成功')</script>"); } else { Response.Write("<script>alert('添加失败')</script>"); } } else { Response.Write("<script>alert('请填写地区')</script>"); } } else { Response.Write("<script>alert('已经存在,换一个试试')</script>"); } }
private static void SaveInitData(ApplicationDbContext context) { if (context.Activities.Count() > 0) { return; } IUserActivityService _userActivityService = new UserActivityService(context); IActivityService _activityService = new ActivityService(context); IRegionService _regionService = new RegionService(context); IUserService _userService = new UserService(context); RecretionalActivity kayaking = new RecretionalActivity { ActivityName = "Kayaking" }; _activityService.AddAnActivity(kayaking); RecretionalActivity camping = new RecretionalActivity { ActivityName = "Camping" }; _activityService.AddAnActivity(camping); RecretionalActivity fishing = new RecretionalActivity { ActivityName = "Fishing" }; _activityService.AddAnActivity(fishing); RecretionalActivity hiking = new RecretionalActivity { ActivityName = "Hiking" }; _activityService.AddAnActivity(hiking); RecretionalActivity sail = new RecretionalActivity { ActivityName = "Sailing" }; _activityService.AddAnActivity(sail); RecretionalActivity biking = new RecretionalActivity { ActivityName = "Biking" }; _activityService.AddAnActivity(biking); ////////////////////// Region japan = new Region { RegionName = "Japan" }; Region usa = new Region { RegionName = "USA" }; Region canada = new Region { RegionName = "Canada" }; Region turk = new Region { RegionName = "Turkey" }; Region india = new Region { RegionName = "India" }; Region pak = new Region { RegionName = "Pakistan" }; Region nepal = new Region { RegionName = "Nepal" }; _regionService.AddRegion(japan); _regionService.AddRegion(usa); _regionService.AddRegion(canada); _regionService.AddRegion(turk); _regionService.AddRegion(india); ApplicationUser safa = new ApplicationUser { UserName = "******", Region = japan, DateOfBirth = new DateTime(2000, 01, 01) }; ApplicationUser alif = new ApplicationUser { UserName = "******", Region = japan, DateOfBirth = new DateTime(2001, 01, 01) }; ApplicationUser hamza = new ApplicationUser { UserName = "******", Region = japan, DateOfBirth = new DateTime(2002, 01, 01) }; ApplicationUser kabir = new ApplicationUser { UserName = "******", Region = japan, DateOfBirth = new DateTime(1990, 01, 01) }; ApplicationUser saif = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1998, 01, 01) }; ApplicationUser salman = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1995, 01, 01) }; ApplicationUser rubel = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1992, 01, 01) }; ApplicationUser talha = new ApplicationUser { UserName = "******", Region = usa, DateOfBirth = new DateTime(1980, 01, 01) }; ApplicationUser rahim = new ApplicationUser { UserName = "******", Region = usa, DateOfBirth = new DateTime(1985, 01, 01) }; ApplicationUser karim = new ApplicationUser { UserName = "******", Region = pak, DateOfBirth = new DateTime(1970, 01, 01) }; ApplicationUser polash = new ApplicationUser { UserName = "******", Region = nepal, DateOfBirth = new DateTime(1988, 01, 01) }; ApplicationUser kamal = new ApplicationUser { UserName = "******", Region = nepal, DateOfBirth = new DateTime(1978, 01, 01) }; _userService.AddUser(safa); _userService.AddUser(alif); _userService.AddUser(hamza); _userService.AddUser(kabir); _userService.AddUser(saif); _userService.AddUser(salman); _userService.AddUser(rubel); _userService.AddUser(talha); _userService.AddUser(rahim); _userService.AddUser(karim); _userService.AddUser(polash); _userService.AddUser(kamal); _userActivityService.ChooseAnActivity(safa, kayaking); _userActivityService.ChooseAnActivity(safa, camping); _userActivityService.ChooseAnActivity(safa, fishing); _userActivityService.ChooseAnActivity(alif, kayaking); _userActivityService.ChooseAnActivity(alif, fishing); _userActivityService.ChooseAnActivity(alif, biking); _userActivityService.ChooseAnActivity(kamal, biking); _userActivityService.ChooseAnActivity(kamal, hiking); _userActivityService.ChooseAnActivity(kamal, sail); _userActivityService.ChooseAnActivity(kabir, biking); _userActivityService.ChooseAnActivity(kabir, camping); _userActivityService.ChooseAnActivity(kabir, sail); _userActivityService.ChooseAnActivity(polash, hiking); _userActivityService.ChooseAnActivity(polash, kayaking); _userActivityService.ChooseAnActivity(karim, biking); _userActivityService.ChooseAnActivity(karim, fishing); _userActivityService.SetRankAnActivity(safa, kayaking, Rating.fiveStar); _userActivityService.SetRankAnActivity(safa, camping, Rating.fourStar); _userActivityService.SetRankAnActivity(safa, fishing, Rating.threeStar); _userActivityService.SetRankAnActivity(alif, kayaking, Rating.threeStar); _userActivityService.SetRankAnActivity(alif, fishing, Rating.twoStar); _userActivityService.SetRankAnActivity(alif, biking, Rating.oneStar); _userActivityService.SetRankAnActivity(kamal, biking, Rating.threeStar); _userActivityService.SetRankAnActivity(kamal, sail, Rating.twoStar); _userActivityService.SetRankAnActivity(kamal, hiking, Rating.oneStar); _userActivityService.SetRankAnActivity(kabir, biking, Rating.threeStar); _userActivityService.SetRankAnActivity(kabir, camping, Rating.twoStar); _userActivityService.SetRankAnActivity(kabir, sail, Rating.oneStar); _userActivityService.SetRankAnActivity(polash, hiking, Rating.fourStar); _userActivityService.SetRankAnActivity(polash, kayaking, Rating.twoStar); _userActivityService.SetRankAnActivity(karim, biking, Rating.twoStar); _userActivityService.SetRankAnActivity(karim, fishing, Rating.fiveStar); }
public void GetTopUsersChoosenByAgeGroupTest() { IUserService _userService = new UserService(_context); IActivityService _activityService = new ActivityService(_context); IRegionService _regionService = new RegionService(_context); IUserActivityService _userActivityService = new UserActivityService(_context); // Region Region bd = new Region { RegionName = "Bangladesh" }; Region usa = new Region { RegionName = "USA" }; Region canada = new Region { RegionName = "Canada" }; Region nepal = new Region { RegionName = "Nepal" }; Region pak = new Region { RegionName = "Pakistan" }; Region bhutan = new Region { RegionName = "Bhutan" }; Region india = new Region { RegionName = "India" }; Region china = new Region { RegionName = "China" }; _regionService.AddRegion(bd); _regionService.AddRegion(usa); _regionService.AddRegion(canada); _regionService.AddRegion(nepal); _regionService.AddRegion(pak); _regionService.AddRegion(india); _regionService.AddRegion(bhutan); _regionService.AddRegion(china); // User ApplicationUser safa = new ApplicationUser { UserName = "******", Region = bd, DateOfBirth = new DateTime(2000, 01, 01) }; ApplicationUser alif = new ApplicationUser { UserName = "******", Region = bd, DateOfBirth = new DateTime(2001, 01, 01) }; ApplicationUser hamza = new ApplicationUser { UserName = "******", Region = bd, DateOfBirth = new DateTime(2002, 01, 01) }; ApplicationUser kabir = new ApplicationUser { UserName = "******", Region = bd, DateOfBirth = new DateTime(1990, 01, 01) }; ApplicationUser saif = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1998, 01, 01) }; ApplicationUser salman = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1995, 01, 01) }; ApplicationUser rubel = new ApplicationUser { UserName = "******", Region = canada, DateOfBirth = new DateTime(1992, 01, 01) }; ApplicationUser talha = new ApplicationUser { UserName = "******", Region = usa, DateOfBirth = new DateTime(1980, 01, 01) }; ApplicationUser rahim = new ApplicationUser { UserName = "******", Region = usa, DateOfBirth = new DateTime(1985, 01, 01) }; ApplicationUser karim = new ApplicationUser { UserName = "******", Region = pak, DateOfBirth = new DateTime(1970, 01, 01) }; ApplicationUser polash = new ApplicationUser { UserName = "******", Region = bhutan, DateOfBirth = new DateTime(1988, 01, 01) }; ApplicationUser kamal = new ApplicationUser { UserName = "******", Region = nepal, DateOfBirth = new DateTime(1978, 01, 01) }; _userService.AddUser(safa); _userService.AddUser(alif); _userService.AddUser(hamza); _userService.AddUser(kabir); _userService.AddUser(saif); _userService.AddUser(salman); _userService.AddUser(rubel); _userService.AddUser(talha); _userService.AddUser(rahim); _userService.AddUser(karim); _userService.AddUser(polash); _userService.AddUser(kamal); var topUsers = _userActivityService.GetTopUsersChoosenByAgeGroup(); Assert.IsNotNull(topUsers); Assert.AreEqual(5, topUsers.FirstOrDefault(f => f.AgeGroup.Equals("18 - 25")).Count); }
public void GetTopFiveRegionChoosenByTheRegisteredUsersTest() { IUserService _userService = new UserService(_context); IActivityService _activityService = new ActivityService(_context); IUserActivityService _userActivityService = new UserActivityService(_context); IRegionService _regionService = new RegionService(_context); // Region Region bd = new Region { RegionName = "Bangladesh" }; Region usa = new Region { RegionName = "USA" }; Region canada = new Region { RegionName = "Canada" }; Region nepal = new Region { RegionName = "Nepal" }; Region pak = new Region { RegionName = "Pakistan" }; Region bhutan = new Region { RegionName = "Bhutan" }; Region india = new Region { RegionName = "India" }; Region china = new Region { RegionName = "China" }; _regionService.AddRegion(bd); _regionService.AddRegion(usa); _regionService.AddRegion(canada); _regionService.AddRegion(nepal); _regionService.AddRegion(pak); _regionService.AddRegion(india); _regionService.AddRegion(bhutan); _regionService.AddRegion(china); // User ApplicationUser safa = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser alif = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser hamza = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser kabir = new ApplicationUser { UserName = "******", Region = bd }; ApplicationUser saif = new ApplicationUser { UserName = "******", Region = canada }; ApplicationUser salman = new ApplicationUser { UserName = "******", Region = canada }; ApplicationUser rubel = new ApplicationUser { UserName = "******", Region = canada }; ApplicationUser talha = new ApplicationUser { UserName = "******", Region = usa }; ApplicationUser rahim = new ApplicationUser { UserName = "******", Region = usa }; ApplicationUser karim = new ApplicationUser { UserName = "******", Region = pak }; ApplicationUser polash = new ApplicationUser { UserName = "******", Region = bhutan }; ApplicationUser kamal = new ApplicationUser { UserName = "******", Region = nepal }; _userService.AddUser(safa); _userService.AddUser(alif); _userService.AddUser(hamza); _userService.AddUser(kabir); _userService.AddUser(saif); _userService.AddUser(salman); _userService.AddUser(rubel); _userService.AddUser(talha); _userService.AddUser(rahim); _userService.AddUser(karim); _userService.AddUser(polash); _userService.AddUser(kamal); var topFiveRegions = _userActivityService.GetTopFiveRegionChoosenByTheRegisteredUsers(); Assert.IsNotNull(topFiveRegions); Assert.AreEqual(bd.RegionName, topFiveRegions.FirstOrDefault().Region.RegionName); Assert.AreEqual(canada.RegionName, topFiveRegions.Skip(1).FirstOrDefault().Region.RegionName); Assert.AreEqual(usa.RegionName, topFiveRegions.Skip(2).FirstOrDefault().Region.RegionName); }