public void GivenObjectIsNotSaved_ItShouldNotGetSavedByOtherSaves() { var options = new DbContextOptionsBuilder <TestContext>() .UseInMemoryDatabase(Helper.GetCallerName()) .Options; var seedData = options.EnsureSeeded(); var seedObject = seedData.First(); using (var context = new TestContext(options)) { var repository = new Repository <TestObject>(context); var list = repository.List(o => o.Id.Equals(seedObject.Id)); var testObject = list.First(); testObject.Name = "ChangedName"; var otherList = repository.List(o => !o.Id.Equals(seedObject.Id)); // Potentially saves all tracked objects repository.Edit(otherList.First()); } using (var context = new TestContext(options)) { var repository = new Repository <TestObject>(context); var list = repository.List(o => o.Id.Equals(seedObject.Id)); var testObject = list.First(); testObject.Name.Should().NotBe("ChangedName"); } }
public ActionResult Report(ReportViewModel model) { ReportManager rm = new ReportManager(); List <Calendar> calList = new List <Calendar>(); ReportViewModel reportViewModel = new ReportViewModel(); List <User> userList = new List <User>(); Repository <User> users = new Repository <User>(); List <string> userNameList = new List <string>(); List <int> userIdList = new List <int>(); userList = users.List(); foreach (var item in userList) { userNameList.Add(item.Name + " " + item.Surname); userIdList.Add(item.Id); } reportViewModel.userList = users.List(); reportViewModel.userNameList = userNameList; reportViewModel.userIdList = userIdList; reportViewModel.calliste = rm.listele2(model.Owner_Id, model.baslangicTarihi, model.bitisTarihi); return(View(reportViewModel)); }
public ActionResult Create() { Kullanici user = Session["login"] as Kullanici; ViewBag.SehirID = new SelectList(repo_sehir.List(), "SehirID", "SehirAdi"); ViewBag.CinsID = new SelectList(repo_cins.List(), "CinsID", "CinsAdi"); ViewBag.HayvanID = new SelectList(repo_hayvan.List(), "HayvanID", "HayvanTuru"); return(View()); }
public static void ReturnNotTrue(User user) { Repository <Notification> repo_not = new Repository <Notification>(); foreach (Notification n in repo_not.List().Where(x => x.User.UserId == user.UserId)) { repo_not.List().FirstOrDefault(x => x.NotificationId == n.NotificationId).IsRead = true; repo_not.Save(); } }
public Test() { //*************Repository'den önce database'i oluşturma işlemleri************* //DataAccessLayer.DatabaseContext db = new DataAccessLayer.DatabaseContext(); //db.Categories.ToList(); //repository test işlemleri //Repository<Category> repo = new Repository<Category>(); List <Category> categories = repo_category.List(); List <Category> categories_filtered = repo_category.List(x => x.Id > 5); }
public IActionResult Index() { Console.WriteLine("dasdasd"); HomeIndexViewModel model = new HomeIndexViewModel() { Languages = languagesRepository.List().Select(x => new SpokenLanguageViewModel() { Label = x.Label, Id = x.Id }).OrderBy(x => x.Label).ToList(), }; return(View(model)); }
public List <Personnel> GetPersonnels(string db_name) { Repository <Personnel> repo_personnel = new Repository <Personnel>(db_name); List <Personnel> personnelList = repo_personnel.List(); return(personnelList); }
public BusinessLayerResult <Test_Master> RemoveTestMasterById(int id) { BusinessLayerResult <Test_Master> res = new BusinessLayerResult <Test_Master>(); Test_Master test_master = Find(x => x.UserId == id); if (test_master != null) { Test_Job res_tj = repo_test_job.List().Where(x => x.job_test_master == test_master).Where(x => x.confirmation == false).FirstOrDefault(); if (res_tj != null) { res.AddError(ErrorMessageCode.TesterHasUncompletedJob, "Test Master'ın henüz tamamlanmamış" + res_tj.test_job_title + " görevi vardır..!"); return(res); } if (Delete(test_master) == 0) { res.AddError(ErrorMessageCode.UserCouldNotRemove, "Kullanıcı Silinemedi"); return(res); } } else { res.AddError(ErrorMessageCode.UserCouldNotFind, "Kullanıcı Bulunamadı"); } return(res); }
public ActionResult Index(string month, string year, int pageIndex = 1) { var transactions = repository.List <Transaction>().OrderByDescending(t => t.Id); int passedMonth = string.IsNullOrWhiteSpace(month) ? DateTime.Now.Month : int.Parse(month); int passedYear = string.IsNullOrWhiteSpace(year) ? DateTime.Now.Year: int.Parse(year); var currentTransactions = transactions.Where(transaction => transaction.When.Month == passedMonth && transaction.When.Year == passedYear); ViewData["pageIndex"] = pageIndex; var count = currentTransactions.Count(); ViewData["pageCount"] = (count / Constants.PAGE_SIZE) + (count % Constants.PAGE_SIZE == 0 ? 0 : 1); var users = repository.List <User>().Where(user => !user.Inactive).ToList(); var transactionModel = new TransactionModel(currentTransactions.ToList(), users, pageIndex - 1); return(View(transactionModel)); }
public ActionResult Index() { //Indexte kullanacağım ViewModeli oluşturuyorum IndexViewModel indexViewModel = new IndexViewModel(); //kisiler tablosunu çekip kisiliste değişkenine atıyorum Repository <User> kisiler = new Repository <User>(); List <User> kisiliste = kisiler.List(); //haftalık çalışma sürelerini ScheduleManager'de hesaplayıp listeye atıyorum. ScheduleManager sm = new ScheduleManager(); List <int> listsure = new List <int>(); listsure = sm.haftalikCalismaSuresi(); //Şu an işte olanları buluyor CurrentManager cm = new CurrentManager(); List <User> currenthere = new List <User>(); foreach (var item in kisiliste) { if (cm.IsHere(item.Id)) { currenthere.Add(item); } } indexViewModel.mevcutkullanici = kisiler.Find(x => x.Id == CurrentSession.User.Id); indexViewModel.kisilist = kisiliste; indexViewModel.kisisure = listsure; indexViewModel.currenthere = currenthere; return(View(indexViewModel)); }
public ActionResult SideMenu() { Repository <TBL_KATEGORILER> repoKategori = new Repository <TBL_KATEGORILER>(); var TBL_KATEGORILER = repoKategori.List(); return(PartialView("SideMenu", TBL_KATEGORILER)); }
public List <Employee> GetCustomer(Employee employeeModel) { Repository <Employee> repo = new Repository <Employee>(employeeModel.CompanyName); var list = repo.List(); return(list); }
//public int SupplierAdd(Employee employeeModel, CompanyGroup companyGroupModel) //Tedarikcilerin kayit olmasi gerceklestiriliyor. //{ // Repository<CompanyGroup> compGroup = new Repository<CompanyGroup>(employeeModel.CompanyName); // compGroup.Insert(new CompanyGroup() // { // Name = companyGroupModel.Name, // Confirmation = companyGroupModel.Confirmation // }); // var list = compGroup.List(); // int lastId=list.Max(x => x.Id); // return lastId; //} public List <CompanyGroup> GetCompanyGroupList(Employee employeeModel) { Repository <CompanyGroup> compGroup = new Repository <CompanyGroup>(employeeModel.CompanyName); var list = compGroup.List(); return(list); }
public List <Employee> GetEmployees(Employee employee) { Repository <Employee> repo_employee = new Repository <Employee>(employee.CompanyName); List <Employee> listEmployee = repo_employee.List(); return(listEmployee); }
public Result <User> LoginUser(LoginViewModel data) { try { Result <User> res = new Result <User>(); var a = repo_user.List(); res.Resultt = repo_user.Find(x => x.Username == data.Username && x.Password == data.Password); if (res.Resultt != null) { if (!res.Resultt.IsActive) { res.AddError(ErrorMessageCode.UserIsNotActive, "Kullanıcı aktifleştirilmemiştir. Lütfen e-posta adresinizi kontrol ediniz."); } } else { res.AddError(ErrorMessageCode.UsernameOrPassWrong, "Kullanıcı adı ya da şifre uyuşmuyor."); } return(res); } catch (Exception e) { throw; } }
public void Initialize(char symbol, int index, ArchitectureStyle style) { if (symbol == 'e') { return; } IResultSet resultSet = Repository.List("facade_item").Filter("style", style.name).Filter("symbol", symbol + "").Filter("index", index + ""); if (resultSet.Count() == 0) { throw new Exception("model not found (style: " + style.name + ", element: " + symbol + index + ")"); } _model = resultSet.Get(0); if (_model == null) { throw new Exception("invalid model (style: " + style.name + ", element: " + symbol + index + ")"); } CacheMetadata(); _invalid = false; }
public async void TestListEntities_ExpectMultipleResults() { var repository = new Repository(client); var values = new List <TestModel>(); for (int i = 10; i < 20; i++) { var value = new TestModel(); value.PopulateProperties(); value.Id = i; values.Add(value); } foreach (var value in values) { await repository.Add(value); } var results = (await repository.List <TestModel>(x => x.Id < 20 && x.Id >= 10)) .OrderBy(x => x.Id) .ToList(); Assert.Equal(values.Count, results.Count); for (int i = 0; i < results.Count; i++) { Assert.True(values[i].IsEqual(results[i])); } }
public BusinessLayerResult <Book> RemoveBookById(int?id) { businessLayerResultBook.BlResult = repositoryBook.Find(x => x.Id == id); if (businessLayerResultBook.BlResult != null) { if (!businessLayerResultBook.BlResult.IsAvailable) { businessLayerResultBook.AddError(ErrorMessageCode.BookCouldNotDeleted, "Kiralanmış kitabı silemezsiniz.."); } else { var borrowsRelatedBooks = repositoryBorrow.List(x => x.Book.Id == id); if (borrowsRelatedBooks.Count > 0) { foreach (var borrowsRelatedBook in borrowsRelatedBooks) { repositoryBorrow.Delete(borrowsRelatedBook); } } repositoryBook.Delete(businessLayerResultBook.BlResult); } } else { businessLayerResultBook.AddError(ErrorMessageCode.BookNotFound, "Silinecek kitap bulunamadı"); } return(businessLayerResultBook); }
public List <Company> GetCompanyList(Employee employeeModel) { Repository <Company> companyList = new Repository <Company>(employeeModel.CompanyName); var list = companyList.List(); return(list); }
public List <EmployeeDTO> List() { using (Repository <Employee> repository = new Repository <Employee>()) { var entities = repository.List(); List <EmployeeDTO> employees = new List <EmployeeDTO>(); foreach (var item in entities) { EmployeeDTO customer = new EmployeeDTO { EmployeeId = item.EmployeeId, FirstName = item.FirstName, LastName = item.LastName, MobilePhone = item.MobilePhone, DepartmentName = item.Position.Department.DepartmentName, PositionName = item.Position.PositionName, RecordStatusName = item.RecordStatus.RecordStatusName }; employees.Add(customer); } return(employees); } }
public BusinessLayerResult <Tester> RemoveTesterById(int id) { BusinessLayerResult <Tester> res = new BusinessLayerResult <Tester>(); Tester tester = Find(x => x.UserId == id); if (tester != null) { Job_Ans res_ja = repo_job_ans.List().Where(x => x.tester == tester).Where(x => x.isSubmitted == true).FirstOrDefault(); if (res_ja != null) { res.AddError(ErrorMessageCode.TesterHasUncompletedJob, "Tester'ın henüz tamamlanmamış" + res_ja.test_job.test_job_title + " görevi vardır..!"); return(res); } if (Delete(tester) == 0) { res.AddError(ErrorMessageCode.UserCouldNotRemove, "Kullanıcı Silinemedi"); return(res); } } else { res.AddError(ErrorMessageCode.UserCouldNotFind, "Kullanıcı Bulunamadı"); } return(res); }
public Test() { //DataAccessLayer.DatabaseContext db = new DataAccessLayer.DatabaseContext(); //db.Categories.ToList(); List <Category> categories = repo_category.List(); //List<Category> categories_filtered = repo_category.List(x => x.Id > 5); }
public void DeleteKisi(int?Id) { Kisi kisi = repositoryKisi.Find(x => x.Id == Id); List <Sube> subes = repositorySube.List(); List <Departman> departmen = repositoryDepartman.List(); List <Ekip> ekip = repositoryEkip.List(); foreach (Sube s in subes) { Kisi sil = s.Kisis.Find(x => x.Id == Id); if (sil != null) { s.Kisis.Remove(sil); } } foreach (Departman s in departmen) { Kisi sil = s.Kisis.Find(x => x.Id == Id); if (sil != null) { s.Kisis.Remove(sil); } } foreach (Ekip s in ekip) { Kisi sil = s.Kisis.Find(x => x.Id == Id); if (sil != null) { s.Kisis.Remove(sil); } } repositoryKisi.Delete(kisi); }
protected override void HandleCommand(IChatClient chatClient, CommandReceivedEventArgs eventArgs) { int offset; if (eventArgs.Arguments.Count == 0) { offset = 0; } else { if (!int.TryParse(eventArgs?.Arguments?.ElementAtOrDefault(0), out int chatUserOffset) || chatUserOffset > 18 || chatUserOffset < -18) { chatClient.SendMessage("UTC offset must be a whole number between -18 and +18"); return; } offset = chatUserOffset; } DateTimeZone timeZone = DateTimeZone.ForOffset(Offset.FromHours(offset)); List <Instant> streamTimes = Repository.List(DataItemPolicy <ScheduleEntity> .All()).Select(x => x.Instant).ToList(); string message = $"Our usual schedule (at UTC {offset}) is: " + string.Join(", ", streamTimes.Select(x => GetTimeDisplay(x, timeZone))); chatClient.SendMessage(message); }
public ServiceResult <IList <TModel> > GetAccessiblePagesForUser <TModel>(long userID) { if (userID == 0) { return(GetPagesByTypes <TModel>(PageType.Public)); } var user = UserRepository.GetByID(userID); if (user.IsSystemAdmin) { return(GetPagesByTypes <TModel>(PageType.Public, PageType.Protected, PageType.System)); } var accessiblePageIds = new List <long>(); foreach (var role in user.Roles.Where(x => x.Enable)) { accessiblePageIds.AddRange(role.Pages.Where(x => !ExcludedPages.Contains(x.ID)).Select(x => x.ID)); } accessiblePageIds = accessiblePageIds.Distinct().ToList(); var result = Repository.List(x => x.Enable && (accessiblePageIds.Contains(x.ID) || x.Type == PageType.Public || (user.UseSystemConfig && x.Type == PageType.System))).ToList(); return(ServiceResult <IList <TModel> > .CreateSuccessResult(Mapper.Map <IList <TModel> >(result))); }
public IList <TResource> TestQuery <TResource, TEntity>(Expression <Func <TResource, bool> > resourcePredicate, Func <TEntity, bool> entityPredicate, string message = null, int?expectedResultCount = null) where TResource : IEntityBase where TEntity : EntityBase { var callingStackFrame = new StackFrame(1); var callingMethod = callingStackFrame.GetMethod(); Assert.That(callingMethod.Name, Does.StartWith("Query" + typeof(TEntity).Name)); var allEntities = Repository.List <TEntity>(); var entities = allEntities.Where(entityPredicate).OrderBy(x => x.Id).ToList(); var fetchedResources = Client.Query <TResource>().Where(resourcePredicate).ToList(); var fetchedResourceIds = fetchedResources.Select(x => x.Id); var entityIds = entities.Select(x => x.Id); Assert.That(fetchedResourceIds, Is.EquivalentTo(entityIds), message); if (expectedResultCount.HasValue) { Assert.That(fetchedResources.Count, Is.EqualTo(expectedResultCount.Value), "Expected result count wrong."); } return(fetchedResources); }
public void QueryCritter_GetMinId_ReturnsMinId() { var expected = Repository.List <Critter>().Min(x => x.Id); Assert.That(Client.Critters.Query().Min(x => x.Id), Is.EqualTo(expected)); Assert.That(Client.Critters.Query().Select(x => x.Id).Min(), Is.EqualTo(expected)); }
private void HandleRandomQuoteRequest(IChatClient triggeringClient) { List <QuoteEntity> quoteEntities = Repository.List(QuoteEntityPolicy.All); int selectedIndex = MyRandom.RandomNumber(0, quoteEntities.Count); triggeringClient.SendMessage(quoteEntities[selectedIndex].ToString()); }
public List <CustomerDTO> List() { using (Repository <Customer> repository = new Repository <Customer>()) { var entities = repository.List(); List <CustomerDTO> customers = new List <CustomerDTO>(); foreach (var item in entities) { CustomerDTO customer = new CustomerDTO { CustomerId = item.CustomerId, CompanyName = item.CompanyName, ContactName = item.ContactName, CityName = item.Town.City.CityName, TownName = item.Town.TownName, Phone = item.Phone }; customers.Add(customer); } return(customers); } }
public int DeleteEkip(int?Id) { Ekip ekip = repository.Find(x => x.Id == Id); List <Sube> subes = repositorySube.List(); List <Departman> departmen = repositoryDepartman.List(); if (ekip.Kisis.Count() != 0) { return(0); } foreach (Sube s in subes) { Ekip sil = s.Ekips.Find(x => x.Id == Id); if (sil != null) { s.Ekips.Remove(sil); } } foreach (Departman s in departmen) { Ekip sil = s.Ekips.Find(x => x.Id == Id); if (sil != null) { s.Ekips.Remove(sil); } } repository.Delete(ekip); return(1); }
public void ListShouldReturnAllPersistedDocumentsOfTheSpecifiedType() { var books = CreateTenBooks(); using (var session = _documentStore.OpenSession()) { var repo = new Repository(session); var retrievedBooks = repo.List<Book>(); Assert.AreEqual(books.Count, retrievedBooks.Count); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { Repository = GetRepository(); var staticPages = Repository.List<StaticPage>(); staticPages.Sort((x, y) => x.CreatedAt.CompareTo(y.CreatedAt)); ViewBag.StaticPages = staticPages; foreach (StaticPage page in ViewBag.StaticPages) { Repository.Detach(page); } base.OnActionExecuting(filterContext); }
public void Run() { using (var sut = new Repository(SERVER, TokenRepository.LoadFrom("ftp.credentials.txt"), "AppZwitschern_TweetStore")) { Console.WriteLine("storing..."); var versandaufträge = new[] { new Versandauftrag() {Id = "1", Termin = new DateTime(2012, 3, 26, 12, 21, 0), Text = "a"}, new Versandauftrag() {Id = "2", Termin = new DateTime(2011, 10, 27, 14, 17, 0), Text = "b"} , null }; var versandt = false; versandaufträge.ToList().ForEach(_ => sut.Store(_, () => versandt = true)); Console.WriteLine(" stored!"); Assert.IsTrue(versandt); Console.WriteLine("listing..."); var filenames = new List<string>(); sut.List(filenames.Add); filenames.ForEach(fn => Console.WriteLine("list {0}", fn)); Assert.AreEqual(3, filenames.Count); Console.WriteLine("loading..."); var results = new List<Versandauftrag>(); filenames.ForEach(fn => sut.Load(fn, results.Add)); Console.WriteLine(" loaded!"); Assert.That(results.Select(_ => _ == null ? null : _.Id).ToArray(), Is.EquivalentTo(new[] {"1", "2", null})); Console.WriteLine("deleting..."); var deleted = false; results.ForEach(va => sut.Delete(va, () => deleted = true)); Console.WriteLine(" deleted!"); Assert.IsTrue(deleted); } }
public void Run() { const string TEST_REPO_PATH = @"c:\appzwitschern"; if (Directory.Exists(TEST_REPO_PATH)) Directory.Delete(TEST_REPO_PATH, true); var repo = new Repository(TEST_REPO_PATH); var va1 = new Versandauftrag() { Text = "a", Termin = new DateTime(2012, 6, 21), Id = Guid.NewGuid().ToString() }; repo.Store(va1, null); var endOfStream = false; var va2 = new Versandauftrag() { Text = "b", Termin = new DateTime(2012, 6, 20), Id = Guid.NewGuid().ToString() }; repo.Store(va2, null); repo.Store(null, () => endOfStream = true); Assert.IsTrue(endOfStream); endOfStream = false; var results = new List<string>(); repo.List(results.Add); Assert.That(results.Select(fn => fn==null ? null : Path.GetFileName(fn)).ToArray(), Is.EquivalentTo(new[] { va1.Id + ".tweet", va2.Id + ".tweet", null })); var resultVAs = new List<Versandauftrag>(); foreach(var fn in results) repo.Load(fn, resultVAs.Add); Assert.That(resultVAs.Select(_ => _==null ? null : _.Text).ToArray(), Is.EquivalentTo(new[]{"a", "b", null})); resultVAs.ForEach(va => repo.Delete(va, () => endOfStream = true)); Assert.AreEqual(0, Directory.GetFiles(TEST_REPO_PATH).Length); Assert.IsTrue(endOfStream); Directory.Delete(TEST_REPO_PATH); }
public void ShouldKnowHowToTakeNDocuments() { using (var session = _documentStore.OpenSession()) { session.Store(new StaticPage { Title = "test" }); session.Store(new StaticPage { Title = "test2" }); session.SaveChanges(); var repository = new Repository(session); Assert.AreEqual(1, repository.List<StaticPage>(1, 1).Count()); } }
public ActionResult Default(string addr, string criteria, string[] sel0, string searchCriteriaTxt, string btnNext, string btnPrevious, string postLat, string postLng, string postZip) { GetTopPlanters(); ViewData["LocLat"] = postLat; ViewData["LocLng"] = postLng; #region fb Coding string appid = ConfigurationManager.AppSettings["AppID"]; ViewData["AppID"] = ConfigurationManager.AppSettings["AppID"]; Repository repoObj = new Repository(); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); if (memberData != null) { } else { FacebookConnect fbConnect = new FacebookConnect(); if (fbConnect.IsConnected) { // message = "You are connected to Facebook"; //Use the wrapper class to get the access token string token = fbConnect.AccessToken; //Alternatively you can just pull the accesstoken out directly with the following line //string token = HttpContext.Request.Cookies["fbs_" + ConfigurationManager.AppSettings["AppID"]]["\"access_token"]; //Note - you need to decode the token or it will be encoded twice. token = HttpUtility.UrlDecode(token); FacebookAPI api = new FacebookAPI(token); JSONObject me = api.Get("/" + fbConnect.UserID); SessionStore.SetSessionValue(SessionStore.FacebookConnect, "FacebookUserLoggedIn"); return RedirectToAction("DiscoverSeed", "Seed"); } else { } } #endregion #region Search Code //Category Selected Seeds Session["SelectedCategory"] = null; str = sel0; string myChoise = null; if (sel0 != null) { for (int i = 0; i < sel0.Length; i++) { if (i == 0) { myChoise = sel0[0]; } else { myChoise = myChoise + "," + sel0[i]; } } } Session["SelectedCategory"] = myChoise; ViewData["SelectedCategory"] = Session["SelectedCategory"]; if (sel0 != null) { if (sel0.Count() == 1 && sel0[0].ToString().Equals("all")) Session["SelectedCategory"] = null; } #endregion #region Home Page Paging if (btnNext == ".." || btnPrevious == ".") { int PageCount = Convert.ToInt32(Session["PageCount"]); int rowCount = Convert.ToInt32(Session["RowCount"]); int NoOfPage = rowCount / 10; if (rowCount % 10 != 0) { NoOfPage += 1; } IList<Seed> lstseed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed); if (btnNext != null && btnNext == "..") { int skipRecord = PageCount * 10; IList<Seed> lst = lstseed.Skip(skipRecord).ToList(); ViewData["SeedList"] = lst.Take(10).ToList(); PageCount += 1; Session["PageCount"] = PageCount; if (PageCount == NoOfPage) { ViewData["NxtVisibility"] = "visibility:hidden;"; ViewData["PrevVisibility"] = "visibility:visible;"; } } else if (btnPrevious != null && btnPrevious == ".") { int takeRecord = (PageCount - 1) * 10; IList<Seed> lst = lstseed.Take(takeRecord).ToList(); ViewData["SeedList"] = lst.Reverse().Take(10).Reverse().ToList(); PageCount -= 1; if (PageCount == 1) { ViewData["NxtVisibility"] = "visibility:visible;"; ViewData["PrevVisibility"] = "visibility:hidden;"; } Session["PageCount"] = PageCount; } ViewData["MarkerList"] = MarkerGenerator((IList<Seed>)ViewData["SeedList"]); return View(); } #endregion #region Search Logic if (addr != "" || criteria != "" || sel0 != null) { string categList = string.Empty; if (sel0 != null) { if (sel0.Count() == 1 && sel0[0].ToString().Equals("all")) { categList = "all"; } else if (sel0.Count() > 0 && !sel0[0].ToString().Equals("all")) { for (int c = 0; c < sel0.Count(); c++) { if (string.IsNullOrEmpty(categList)) categList = "'" + sel0[c].ToString() + "'"; else categList = categList + ",'" + sel0[c].ToString() + "'"; } } else if (sel0.Count() > 1 && sel0[0].ToString().Equals("all")) { for (int c = 1; c < sel0.Count(); c++) { if (string.IsNullOrEmpty(categList)) categList = "'" + sel0[c].ToString() + "'"; else categList = categList + ",'" + sel0[c].ToString() + "'"; } } } //Neighborhood try { if (!string.IsNullOrEmpty(addr)) { if (!addr.Contains(',')) { string[] checkString = addr.Trim().Split(' '); if (checkString.Length > 1) { int splitCount = checkString.Count(); if (checkString[splitCount - 1].ToString().Length == 2) { int idx = addr.LastIndexOf(' '); string idxString = addr.Insert(idx, ","); addr = idxString; } } } } } catch { } string[] splitString1 = addr.Split(','); string cityName1 = string.Empty; if (splitString1.Length > 0) { string citySplit = splitString1[0].ToString(); if (citySplit.Contains("Your Location")) citySplit = citySplit.Replace("Your Location : ", ""); cityName1 = citySplit; } ViewData["CatLocation"] = cityName1; IList<Seed> newListSeed = this.getHomeSearchResult(cityName1, categList, criteria, postZip, criteria); ViewData["SeedList"] = newListSeed.Distinct().ToList(); if (newListSeed.Count > 0) { ViewData["SeedList"] = newListSeed.OrderByDescending(x => x.createDate).ToList(); } else { newListSeed = repoObj.List<Seed>().Where(x => (x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING))).Take(20).OrderByDescending(x => x.createDate).ToList(); ViewData["SeedList"] = newListSeed; ViewData["CitySearchMsg"] = "<span>Sorry, no seeds planted in '" + cityName1 + "' area. Showing latest additions.</span>"; string streamFeed = "Select top 20 * from Seed order by createDate desc"; SessionStore.SetSessionValue(SessionStore.DefaultFeed, streamFeed); } if (newListSeed.Count > 0) SessionStore.SetSessionValue(SessionStore.DiscoverSeed, newListSeed); Session["RowCount"] = newListSeed.Count(); Session["PageCount"] = "1"; ViewData["PrevVisibility"] = "visibility:hidden;"; if (newListSeed.Count > 10) ViewData["NxtVisibility"] = "visibility:visible;"; else ViewData["NxtVisibility"] = "visibility:hidden;"; CommonMethods objCmnMethods = new CommonMethods(); string locLatLng = Session["LocLatLng"].ToString(); string[] locLatLngSplit = locLatLng.Split(','); foreach (Seed sd in newListSeed) { sd.seedDistance = (int)objCmnMethods.distance(Convert.ToDouble(locLatLngSplit[0].ToString()), Convert.ToDouble(locLatLngSplit[1].ToString()), Convert.ToDouble(sd.Location.localLat), Convert.ToDouble(sd.Location.localLong)); } if (newListSeed.Count > 0) SessionStore.SetSessionValue(SessionStore.DiscoverSeed, newListSeed); ViewData["SeedList"] = newListSeed.OrderBy(x => x.seedDistance).ToList(); ViewData["MarkerList"] = MarkerGenerator(newListSeed); ViewData["Criteria"] = criteria; if (newListSeed.Count > 0) { CategoryAction objCat = new CategoryAction(); IList<Category> categ = new List<Category>(); Category c = null; foreach (Seed s in newListSeed) { IList<Category> listCategory = s.Categories.ToList(); if (listCategory.Count > 0) { foreach (Category c1 in listCategory) { c = objCat.GetCategoryById(s.Categories.FirstOrDefault().id.ToString()); if (c != null) categ.Add(c); } } } ViewData["SeedCategories"] = categ.Distinct().ToList(); } } #endregion return View(); }
public ActionResult Default() { #region PreviousCoding Repository repoObj = new Repository(); Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); if (memberData != null) { //ViewData["LocationData"] = locations; //ViewData["Memberlocation"] = memberLocation; } else { string logoutString = TempData["Logout"] as string; if (logoutString != "Logout") { const string myFacebookApiKey = "101151816623334"; const string myFacebookSecret = "65f49046dce2d1f54d6991e43c4af675"; var connectSession = new ConnectSession(myFacebookApiKey, myFacebookSecret); if (connectSession.IsConnected()) { ViewData["FBConnected"] = true; var api = new Api(connectSession); ViewData["FBUser"] = api.Users.GetInfo(); ViewData["UserID"] = api.Users.GetInfo().uid; SessionStore.SetSessionValue(SessionStore.FacebookConnect, "FacebookUserLoggedIn"); string[] fbDetails = new string[2]; fbDetails[0] = Convert.ToString("fb_" + api.Users.GetInfo().uid); fbDetails[1] = api.Users.GetInfo().name; SessionStore.SetSessionValue("FacebookDetails", fbDetails); api.Session.Logout(); connectSession.Logout(); return RedirectToAction("FBUser", "Member"); } } } #endregion GetTopPlanters(); CommonMethods objCmnMethods = new CommonMethods(); string strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress; if (strIpAddress == "127.0.0.1") strIpAddress = "61.246.241.162"; string citySearch = string.Empty; string stateSearch = string.Empty; string zipCodeSearch = string.Empty; string latSearch = string.Empty; string lngSearch = string.Empty; string[] currentAddress; string ipLocation = objCmnMethods.MaxMindIPData(strIpAddress); if (!string.IsNullOrEmpty(ipLocation) && (!ipLocation.Contains("IP_NOT_FOUND"))) { //IPaddressAPI currentAddress = ipLocation.Split(','); if (string.IsNullOrEmpty(currentAddress[1].Replace("\"", "").ToString())) stateSearch = "AZ"; else { stateSearch = currentAddress[1].Replace("\"", "").ToString(); //stateSearch = "WA"; } if (string.IsNullOrEmpty(currentAddress[2].ToString())) citySearch = "Phoenix"; else { citySearch = currentAddress[2].Replace("\"", "").ToString(); //citySearch = "Seattle"; } if (string.IsNullOrEmpty(currentAddress[3].Replace("\"", "").ToString())) { //zipCodeSearch = "85027"; SeedAction objS = new SeedAction(); LocationAction objLocation = new LocationAction(); string cityId = objLocation.GetCityIdByCityName(citySearch, stateSearch); zipCodeSearch = objS.GetZipOfSeedByCityId(cityId); } else zipCodeSearch = currentAddress[3].Replace("\"", "").ToString(); latSearch = currentAddress[4].Replace("\"", "").ToString(); lngSearch = currentAddress[5].Replace("\"", "").ToString(); } else { //MaxMind ipLocation = objCmnMethods.IP2AddressMaxMind(); currentAddress = ipLocation.Split('\''); if (string.IsNullOrEmpty(currentAddress[7].ToString())) stateSearch = "AZ"; else stateSearch = currentAddress[7].ToString(); if (string.IsNullOrEmpty(currentAddress[5].ToString())) citySearch = "Phoenix"; else citySearch = currentAddress[5].ToString(); if (string.IsNullOrEmpty(currentAddress[15].ToString())) zipCodeSearch = "85027"; else zipCodeSearch = currentAddress[15].ToString(); latSearch = currentAddress[11].ToString(); lngSearch = currentAddress[13].ToString(); } ViewData["LocLat"] = latSearch; ViewData["LocLng"] = lngSearch; Session["LocLatLng"] = latSearch + "," + lngSearch; SeedAction objSeed = new SeedAction(); IList<Seed> lstSeed = getHomeSearchResult(citySearch, "", "", zipCodeSearch, ""); if (lstSeed.Count > 0) { ViewData["SeedList"] = lstSeed.OrderByDescending(x => x.createDate).ToList(); ViewData["userLocation"] = "Your Location : " + citySearch + ", " + stateSearch; ViewData["CatLocation"] = citySearch + ", " + stateSearch; } else { lstSeed = repoObj.List<Seed>().Where(x => x.status.Equals(SystemStatements.STATUS_NEW) || x.status.Equals(SystemStatements.STATUS_GROWING)).OrderByDescending(x => x.createDate).Take(20).ToList(); ViewData["SeedList"] = lstSeed; ViewData["userLocation"] = "Your Location : " + citySearch + ", " + stateSearch; ViewData["CatLocation"] = citySearch + ", " + stateSearch; ViewData["CitySearchMsg"] = "<span>Sorry, no seeds planted in '" + citySearch + "' area. Showing latest additions.</span>"; string streamFeed = "Select top 20 * from Seed order by createDate desc"; SessionStore.SetSessionValue(SessionStore.DefaultFeed, streamFeed); } string advSearch = TempData["DiscoverSeed"] as string; if (advSearch != "AdvanceSearch") { if (lstSeed.Count > 0) SessionStore.SetSessionValue(SessionStore.DiscoverSeed, lstSeed); } if (SessionStore.GetSessionValue(SessionStore.DiscoverSeed) != null) lstSeed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed); int rowCount = lstSeed.Count; Session["RowCount"] = rowCount; Session["PageCount"] = "1"; ViewData["SeedList"] = lstSeed.Take(10).ToList(); ViewData["PrevVisibility"] = "visibility:hidden;"; if (lstSeed.Count > 10) ViewData["NxtVisibility"] = "visibility:visible;"; else ViewData["NxtVisibility"] = "visibility:hidden;"; foreach (Seed sd in lstSeed) { sd.seedDistance = (int)objCmnMethods.distance(Convert.ToDouble(latSearch), Convert.ToDouble(lngSearch), Convert.ToDouble(sd.Location.localLat), Convert.ToDouble(sd.Location.localLong)); } if (lstSeed.Count > 0) SessionStore.SetSessionValue(SessionStore.DiscoverSeed, lstSeed); ViewData["SeedList"] = lstSeed.OrderBy(x => x.seedDistance).ToList(); ViewData["MarkerList"] = MarkerGenerator((IList<Seed>)ViewData["SeedList"]); //ListBox if (Session["SelectedCategory"] != null) { Session["SelectedCategory"] = null; } else { if (str != null) { string myString = null; for (int i = 0; i < str.Length; i++) { if (i == 0) { myString = str[i]; } else { myString = myString + "," + str[i]; } } Session["SelectedCategory"] = myString; ViewData["SelectedCategories"] = myString; } } //ListBox if (lstSeed.Count > 0) { CategoryAction objCat = new CategoryAction(); IList<Category> categ = new List<Category>(); Category c = null; foreach (Seed s in lstSeed) { IList<Category> listCategory = s.Categories.ToList(); if (listCategory.Count > 0) { foreach (Category c1 in listCategory) { c = objCat.GetCategoryById(s.Categories.FirstOrDefault().id.ToString()); if (c != null) categ.Add(c); } } } ViewData["SeedCategories"] = categ.Distinct().ToList(); } return View(); }
public void GetTopPlanters() { #region Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject); Repository repoObj = new Repository(); IList<TopSeedPlanter> listTopPlanters = repoObj.ListP<TopSeedPlanter>("Usp_GetTopSeedPlanter").ToList(); IList<Member> mostFollowedList = repoObj.List<Member>(x => x.id.Equals(x.FollowPeoples1.FirstOrDefault().Member1.id)).OrderByDescending(x => x.FollowPeoples1.Count()).Take(10).ToList(); if (memberData != null) { listTopPlanters = listTopPlanters.Where(x => x.id != memberData.id).ToList(); mostFollowedList = mostFollowedList.Where(x => x.id != memberData.id).ToList(); } ViewData["TopPlanters"] = listTopPlanters; ViewData["MostFollowed"] = mostFollowedList; #endregion }
public void ShouldListSecondPage() { using (var session = _documentStore.OpenSession()) { session.Store(new StaticPage { Title = "test2", UpdatedAt = DateTime.Now.AddMinutes(1) }); session.Store(new StaticPage { Title = "test", UpdatedAt = DateTime.Now }); session.SaveChanges(); var repository = new Repository(session); Assert.AreEqual("test", repository.List<StaticPage>(2, 1).First().Title); } }