public ActionResult Index() { HomePageModel homePageModel = new HomePageModel(); BindBasePageModel(homePageModel); return View(homePageModel); }
public ActionResult Faq() { HomePageModel homePageModel = new HomePageModel(); this.BindBasePageModel(homePageModel); return View("../CustomCode/VICommerce/" + LicenseContext.AccountDomain + "/FAQ", homePageModel); }
public ActionResult Index(int? clove, string searchstring, string sortOrder, string currentFilter, int? page, int? article_id) { if (!Request.IsAuthenticated) UserInformation.User = null; var list = new List<HomePageModel>(); var model = new HomePageModel(); model.CloveID = clove; // paging if (searchstring != null) page = 1; else searchstring = currentFilter; model.PageNumber = page ?? 1; ViewBag.CurrentFilter = searchstring; // search model.CloveSearch = searchstring; // sorting ViewBag.TitleSort = String.IsNullOrEmpty(sortOrder) ? "title_asc" : ""; ViewBag.AuthorSort = String.IsNullOrEmpty(sortOrder) ? "author_asc" : ""; ViewBag.VoteSort = String.IsNullOrEmpty(sortOrder) ? "votes_desc" : ""; model.CloveSort = sortOrder; // votes if (article_id != null) { v_votes vote = new v_votes { v_p_post = article_id ?? default(int), v_upvote = true, v_date = DateTime.Now }; db.v_votes.Add(vote); db.SaveChanges(); } list.Add(model); ViewBag.clove = new SelectList(model.Cloves, "c_id", "c_name"); return View(list); }
public HomePageModel GetPageContent(string url) { //get the page var web = new HtmlWeb(); var document = web.Load(url); var page = document.DocumentNode; var result = new HomePageModel(); result.DanhSachTruyenMain = new List <TruyenHomePageModel>(); var newChapterSection = page.SelectNodes("//div[contains(@id, 'new-chapter')]").First(); var resultWriteToLog = new List <string>(); foreach (var item in newChapterSection.SelectNodes("//span[contains(@class, 'manga')]")) { var parentDiv = item.ParentNode; var tenTruyen = item.InnerText.Trim(' '); var truyenUrl = item.FirstChild.Attributes[0].Value; var chuongMoiNhatNode = parentDiv.ChildNodes.Where(q => q.Attributes.Any(a => a.Name == "class" && a.Value == "chapter")).First(); var chuongMoiNhat = chuongMoiNhatNode.InnerText.Trim(' ', '\r', '\n'); var ngayCapNhatNode = parentDiv.ChildNodes.Where(q => q.Attributes.Any(a => a.Name == "class" && a.Value == "current-date")).First(); var ngayCapNhat = ngayCapNhatNode.InnerText.Trim(' ', '\r', '\n'); result.DanhSachTruyenMain.Add(new TruyenHomePageModel { TenTruyen = tenTruyen, Url = truyenUrl, ChuongMoiNhat = chuongMoiNhat, NgayCapNhat = ngayCapNhat }); var logText = string.Format("{0}\t{1}", tenTruyen, truyenUrl); resultWriteToLog.Add(logText); } File.WriteAllText(@"E:\WriteText.txt", string.Join("\r\n", resultWriteToLog)); return(result); }
public ActionResult Index(HomePageModel model) { try { if (ModelState.IsValid) { var result = DownloadPageAsync(model.URL).Result; var sanatisedResult = StripHTML(result); List <CloudModel> wordsCloud = WordCount(sanatisedResult); model.cloudModel = wordsCloud.OrderBy(a => Guid.NewGuid()).ToList(); } else { ModelState.AddModelError("URL", "There is an Error with URL"); } } catch { ModelState.AddModelError("URL", "Error checking URL"); } return(View(model)); }
public ActionResult AdminLogin(string email, string sifre) { HomePageModel model = new HomePageModel(); DatabaseContext db = new DatabaseContext(); var login = (from m in db.admin where m.adminEmail == email && m.adminSifre == sifre select m).FirstOrDefault(); if (login != null) { Session["adminID"] = login.adminID; model.admin = login; } else { ViewBag.result = "ID ya da şifre yanlış."; ViewBag.status = "danger"; return(View()); } return(RedirectToAction("AdminIndex")); }
// GET: BookReadingEvent public ActionResult Index() { List <BookReadingEventDTO> eventListDTO = BusinessLayerBookReadingEvent.GetAllEvents(); HomePageModel homePageModel = new HomePageModel(); if (Session["userID"] == null) { foreach (BookReadingEventDTO evt in eventListDTO) { if (evt.Type == EventType.Public) { if (evt.Date < DateTime.Now) { homePageModel.PastEvents.Add(evt); } else { homePageModel.FutureEvents.Add(evt); } } } } else { foreach (BookReadingEventDTO evt in eventListDTO) { if (evt.Date < DateTime.Now) { homePageModel.PastEvents.Add(evt); } else { homePageModel.FutureEvents.Add(evt); } } } return(View(homePageModel)); }
public ActionResult Index(Guid?idpId) { var model = new HomePageModel { AssertionModel = AssertionModel.CreateFromConfiguration(), }; if (idpId.HasValue) { var fileData = GetCachedConfiguration(idpId.Value); if (fileData != null) { if (!string.IsNullOrEmpty(fileData.DefaultAssertionConsumerServiceUrl)) { // Override default StubIdp Acs with Acs from IdpConfiguration model.AssertionModel.AssertionConsumerServiceUrl = fileData.DefaultAssertionConsumerServiceUrl; } model.CustomDescription = fileData.IdpDescription; model.AssertionModel.NameId = null; model.HideDetails = fileData.HideDetails; } } var requestData = Request.ToHttpRequestData(); if (requestData.QueryString["SAMLRequest"].Any()) { var decodedXmlData = Saml2Binding.Get(Saml2BindingType.HttpRedirect) .Unbind(requestData); var request = Saml2AuthenticationRequest.Read(decodedXmlData); model.AssertionModel.InResponseTo = request.Id; model.AssertionModel.AssertionConsumerServiceUrl = request.AssertionConsumerServiceUrl.ToString(); model.AssertionModel.AuthnRequestXml = decodedXmlData; } return(View(model)); }
public ActionResult AdminNotification(string btnLogout, string txtDuyuru, string btnDegistir, string btnDuyur) { if (btnLogout != null) { Session["adminID"] = null; return(RedirectToAction("AdminLogin")); } HomePageModel model = new HomePageModel(); DatabaseContext db = new DatabaseContext(); var adminID = Convert.ToInt32(Session["adminID"]); var admin = (from m in db.admin where m.adminID == adminID select m).FirstOrDefault(); if (btnDuyur != null) { admin.duyuru = txtDuyuru; db.SaveChanges(); model.admin = db.admin.Where(x => x.adminID == adminID).FirstOrDefault(); return(RedirectToAction("AdminNotification")); } if (btnDegistir != null) { if (admin.duyuruGoster == 1) { admin.duyuruGoster = 0; } else { admin.duyuruGoster = 1; } db.SaveChanges(); model.admin = db.admin.Where(x => x.adminID == adminID).FirstOrDefault(); return(RedirectToAction("AdminNotification")); } return(View(model)); }
public MainPage() { this.navigationHelper = new NavigationHelper(this); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; userService = UserService.GetInstance(); weatherService = WeatherService.GetInstance(); settingService = SettingService.GetInstance(); colorService = ColorService.GetInstance(); userRespose = new GetUserRespose(); userCityRespose = new GetUserCityRespose(); weatherRespose = new GetWeatherRespose(); weatherTypeRespose = new GetWeatherTypeRespose(); settingAutoUpdateTimeRepose = new GetSettingAutoUpdateTimeRepose(); colorResponse = new GetColorRespose(); homePageModel = new HomePageModel(); this.InitializeComponent(); Loaded += MainPage_Loaded; }
public ActionResult Index() { HomePageModel homePageContent = pageContentService.HomePage; HomeViewModel viewModel = new HomeViewModel() { MainHeading = homePageContent.MainHeading, Banners = homePageContent.Banners.Select( a => new BannerViewModel( ImageHelper.MapImageToViewModel(a.BannerOverlayLogo), new ResponsiveImageViewModel( a.Image.Title, TourtechUrlHelper.GetImageUrl(a.Image.ImageRelativeUrl), TourtechUrlHelper.GetImageUrl(a.Image.MobileImageRelativeUrl) ), a.OverlayText, TourtechUrlHelper.GetCategoryUrl(a.OverlayLinkCategoryName), a.AlternateColorTheme ) ), CategoryTiles = homePageContent.CategoryTiles.Select( b => new CategoryTileViewModel( ImageHelper.MapImageToViewModel(b.Image), b.Text, b.LinkText, TourtechUrlHelper.GetCategoryUrl(b.LinkCategoryName) ) ), Products = ProductHelper.MapProductsToViewModels(productsService.GetProducts()), Title = homePageContent.MetaData.Title, MetaDescription = homePageContent.MetaData.MetaDescription } ; SetLayout(viewModel); return(View(viewModel)); }
public ActionResult Index(int currentpage = 1) { var model = new HomePageModel { CurrentPage = currentpage }; try { var allOrders = _tableOperations.GetAll <OrdersViewModel>("sampleSales", "orders", _loggingService); model.Count = allOrders.Count(); model.Orders = allOrders.OrderBy(d => d.Order_Id) .Skip((model.CurrentPage - 1) * model.PageSize) .Take(model.PageSize); } catch (ConnectorNotFoundException) { ViewData["ConnectorNeeded"] = "Connector sampleSales not set up or disabled. Go to the dashboard to configure."; model.Orders = Array.Empty <OrdersViewModel>(); } return(View(model)); }
private void ReadCustomIdpConfig(Guid?idpId, HomePageModel model) { if (idpId.HasValue) { var fileData = GetCachedConfiguration(idpId.Value); if (fileData != null) { if (!string.IsNullOrEmpty(fileData.DefaultAssertionConsumerServiceUrl)) { // Override default StubIdp Acs with Acs from IdpConfiguration model.AssertionModel.AssertionConsumerServiceUrl = fileData.DefaultAssertionConsumerServiceUrl; } if (!string.IsNullOrEmpty(fileData.DefaultAssertionConsumerServiceUrl)) { model.AssertionModel.Audience = fileData.DefaultAudience; } model.CustomDescription = fileData.IdpDescription; model.AssertionModel.NameId = null; model.HideDetails = fileData.HideDetails; } } }
public ActionResult Index(Guid?idpId, HomePageModel model) { if (ModelState.IsValid) { var response = model.AssertionModel.ToSaml2Response(); return(Saml2Binding.Get(model.AssertionModel.ResponseBinding) .Bind(response).ToActionResult()); } if (model.AssertionModel == null) { model.AssertionModel = AssertionModel.CreateFromConfiguration(); } ; if (HandleReceivedAuthnReqest(model)) { ReadCustomIdpConfig(idpId, model); } return(View(model)); }
public ActionResult Index() { var model = new HomePageModel { Data = new List <DisplaySectionModel>() }; model.TopArticles = Repository.GetArticles(10); var sections = Repository.GetSections(); foreach (var s in sections) { var sectionArticles = Repository.GetArticles((Constants.Section)s.id, 5); model.Data.Add(new DisplaySectionModel { Section = s, Articles = sectionArticles }); } SetNavLinks(sections); return(View(model)); }
public string getMessagesAmount(string currentName) { HomePageModel vm = new HomePageModel(); vm.NewMessages = 0; foreach (TwoThorProfile p in _context.DbTwoThorProfileList) { if (currentName.Equals(p.Email)) { vm.IsTwoThor = true; break; } } foreach (ChatMessage m in _context.DbChatLog) { if (!m.read && m.RecipientName.Equals(currentName)) { vm.NewMessages++; } } return(vm.NewMessages.ToString()); }
public ActionResult SearchPosts(string postTerm) { List <HomeGroupModel> homePageGroups = db.Groups .Select(group => new HomeGroupModel { CourseCode = group.CourseCode, CourseName = group.CourseName, CourseDescription = group.CourseDescription, CoursePictureUrl = group.CoursePictureUrl }).ToList(); List <HomePostModel> homePagePosts = db.Posts .Where(p => p.Title.Contains(postTerm) || p.Content.Contains(postTerm)) .Include(p => p.UserOwner) .Include(p => p.Group) .OrderByDescending(p => p.Created) .Select(post => new HomePostModel() { Id = post.Id, Title = post.Title, Content = post.Content, Created = post.Created, NumberOfLikes = post.NumberOfLikes, NumberOfReplies = post.NumberOfReplies, UserOwner = post.UserOwner, Group = post.Group }).ToList(); HomePageModel model = new HomePageModel() { HomeGroups = homePageGroups, HomePosts = homePagePosts }; return(View("Index", model)); }
public ActionResult AccountSetting() { if (Convert.ToInt32(Session["loginDurum"]) != 1) { return(RedirectToAction("Index", "Home")); } DatabaseContext db = new DatabaseContext(); HomePageModel model = new HomePageModel(); var kullaniciID = Convert.ToInt32(Session["kullaniciID"]); if (Convert.ToInt32(Session["loginDurum"]) != 1) { model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Session["sepetAdetZiyaretci"] = (from m in db.sepet where m.kullaniciID == null select m.urunAdet).DefaultIfEmpty(0).Sum(); } else { model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Session["sepetAdetKullanici"] = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID select m.urunAdet).DefaultIfEmpty(0).Sum(); } if (TempData["errorRegister"] != null) { ViewData["errorRegister"] = TempData["errorRegister"]; } if (TempData["errorRegisterEmpty"] != null) { ViewData["errorRegisterEmpty"] = TempData["errorRegisterEmpty"]; } model.kullanici = db.kullanici.Where(x => x.kullaniciID == kullaniciID).FirstOrDefault(); model.kategoriler = db.kategoriler.ToList(); //select * from kategoriler return(View(model)); }
public ActionResponse SetSettings(HomePageModel model) { using (var unitWork = new UnitOfWork(context)) { ActionResponse response = new ActionResponse(); try { var settings = unitWork.HomePageRepository.GetOne(h => h.Id != 0); if (settings == null) { unitWork.HomePageRepository.Insert(new EFHomePageSettings() { AIMSTitle = model.AIMSTitle, AIMSTitleBarText = model.AIMSTitleBarText, IntroductionHeading = model.IntroductionHeading, IntroductionText = model.IntroductionText }); } else { settings.AIMSTitle = model.AIMSTitle; settings.AIMSTitleBarText = model.AIMSTitleBarText; settings.IntroductionHeading = model.IntroductionHeading; settings.IntroductionText = model.IntroductionText; unitWork.HomePageRepository.Update(settings); } unitWork.Save(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); } }
public void Init() { //分数统计界面UI显示 Text txt = again.transform.Find("Text").GetComponent <Text>(); txt.text = "再来一次"; string[] str = TestPaperModel.GetInstance().TotalCount().Split('_'); int right = int.Parse(str[0]); int wrong = int.Parse(str[1]); double a = ((double)right) / (right + wrong); double ratio = Math.Round(a, 4) * 100; string text = @"答对题目: " + right + "\n" + "答错题目: " + wrong + "\n" + "正确率: " + ratio.ToString() + "%"; transform.Find("Text").GetComponent <Text>().text = text; //发送统计分数时间戳 string guid = BitConverter.ToUInt64(Guid.NewGuid().ToByteArray(), 0).ToString(); //格式:guid+开始时间+结束时间+分数 string msg = "id=" + guid + "&" + HomePageModel.GetInstance().SendTimeStampStr() + "&score=" + ratio.ToString(); StartCoroutine(SendMsg(msg)); Settle(); }
public ActionResult Index() { List <HomeGroupModel> homePageGroups = db.Groups.Select(group => new HomeGroupModel { CourseCode = group.CourseCode, CourseName = group.CourseName, CourseDescription = group.CourseDescription, CoursePictureUrl = group.CoursePictureUrl }).ToList(); List <HomePostModel> homePagePosts = db.Posts .Include(p => p.UserOwner) .Include(p => p.Group) .OrderByDescending(p => p.Created) .Select(post => new HomePostModel() { Id = post.Id, Title = post.Title, Content = post.Content.Length <= 80 ? post.Content : post.Content.Substring(0, 80) + "...", Created = post.Created, NumberOfLikes = post.NumberOfLikes, NumberOfReplies = post.NumberOfReplies, UserOwner = post.UserOwner, Group = post.Group }).ToList(); HomePageModel model = new HomePageModel() { HomeGroups = homePageGroups, HomePosts = homePagePosts }; return(View(model)); }
public ActionResult Index() { var homePage = new HomePageModel(); var posts = db.Posts.Include(p => p.Author).OrderByDescending(post => post.Date).Take(5).ToList(); var tags = db.Tags.ToList(); SortedDictionary <string, int> tagsCount = new SortedDictionary <string, int>(); foreach (var tag in tags) { if (!tagsCount.ContainsKey(tag.Name)) { tagsCount.Add(tag.Name, 1); } else { tagsCount[tag.Name]++; } } homePage.Post = posts; homePage.TagCount = tagsCount; return(View(homePage)); }
public ActionResult AccountSetting(string btnUpdate, string btnLogout, string btnSil, string eposta, string sifre, string btnLogin, string firstname, string lastname, string email, string password, string address, string country, string btnRegister, int?isRegisterOk) { DatabaseContext db = new DatabaseContext(); HomePageModel model = new HomePageModel(); var kullaniciID = Convert.ToInt32(Session["kullaniciID"]); model.kategoriler = db.kategoriler.ToList(); model.kullanici = db.kullanici.Where(x => x.kullaniciID == kullaniciID).FirstOrDefault(); if (firstname == "" || lastname == "" || email == "" || password == "" || address == "" || country == "") { TempData["errorRegisterEmpty"] = 1; return(RedirectToAction("AccountSetting")); } if (btnUpdate != null) { var kullanici = model.kullanici; kullanici.kullaniciAd = firstname; kullanici.kullaniciSoyAd = lastname; kullanici.email = email; kullanici.kullaniciSifre = password; kullanici.Adres = address; kullanici.Country = country; Session["kullaniciAd"] = firstname; Session["kullaniciSoyAd"] = lastname; Session["kullaniciemail"] = email; Session["kullaniciSifre"] = password; Session["kullaniciAdres"] = address; Session["kullaniciUlke"] = country; db.SaveChanges(); return(RedirectToAction("AccountSetting")); } if (btnSil != null) { model.kategoriler = db.kategoriler.ToList(); model.urunler = db.urunler.ToList(); if (Convert.ToInt32(Session["loginDurum"]) == 1) { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } //ZİYATETÇİ else { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); } } if (btnLogin != null) { try { var kullanici = (from m in db.kullanici where m.email == eposta && m.kullaniciSifre == sifre select m).FirstOrDefault(); Session["kullaniciID"] = kullanici.kullaniciID; Session["kullaniciAd"] = kullanici.kullaniciAd; Session["kullaniciSoyAd"] = kullanici.kullaniciSoyAd; Session["kullaniciemail"] = kullanici.email; Session["kullaniciSifre"] = kullanici.kullaniciSifre; Session["kullaniciAdres"] = kullanici.Adres; Session["kullaniciUlke"] = kullanici.Country; Session["kullaniciUyelikTarihi"] = kullanici.memberSince; Session["loginDurum"] = 1; model.urunler = db.urunler.ToList(); //select * from urunler kullaniciID = Convert.ToInt32(Session["kullaniciID"]); var ziyaretciSepetList = (from m in db.sepet where m.kullaniciID == null select m).ToList(); foreach (var item in ziyaretciSepetList) { int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet == 0) { item.kullaniciID = (from m in db.kullanici where m.kullaniciID == kullaniciID select m).FirstOrDefault(); db.sepet.Add(item); db.SaveChanges(); } else { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m).FirstOrDefault(); sepetGüncelle.urunAdet += item.urunAdet; db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); //last } return(RedirectToAction("AccountSetting")); } catch (Exception) { //KULLANICI BULUNAMADI. model.urunler = db.urunler.ToList(); ViewData["alertLogin"] = "******"; } } if (btnLogout != null) { Session["loginDurum"] = 0; model.urunler = db.urunler.ToList(); model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); return(RedirectToAction("Index", "Home")); } return(View(model)); }
//public ActionResult SchemaTableDesigner(string ID, string mode = "edit") //{ // var model = new SchemaTableDesignerModel(this, null); // if (mode == "edit") // App.Schema.ReloadObjectCache(Guid.Parse(ID)); // model.EditedObject = App.Schema.GetObject<SchemaTable>(Guid.Parse(ID)); // model.StartEditing(); // return View(@"~\MODULES\BUHTA\CORE\SCHEMA\SCHEMA-TABLE\SchemaTableDesignerView.cshtml", model); //} //public ActionResult SchemaDesigner() //{ // var model = new SchemaDesignerModel(this, null); // return View(@"~\MODULES\BUHTA\CORE\SCHEMA\DESIGNER\SchemaDesignerView.cshtml", model); //} public ActionResult Index() { var model = new HomePageModel(this, null); return View(@"~\MODULES\BUHTA\CORE\HOME-PAGE\HomePageView.cshtml", model); }
/// <summary> /// 在此页将要在 Frame 中显示时进行调用。 /// </summary> /// <param name="e">描述如何访问此页的事件数据。 /// 此参数通常用于配置页。</param> protected override void OnNavigatedTo(NavigationEventArgs e) { homePageModel = e.Parameter as HomePageModel; this.LVFeature.ItemsSource = homePageModel.DailyList; }
public ActionResult SendMail(HomePageModel model) { SendEmail(model.Email, model.UserName, model.Subject, model.Body); SaveEmail(model.Email, model.UserName, model.Subject, model.Body); return(RedirectToAction("Index", "Home")); }
// GET: Admin public ActionResult AdminIndex() { if (Session["adminID"] == null) { return(RedirectToAction("AdminLogin")); } HomePageModel model = new HomePageModel(); DatabaseContext db = new DatabaseContext(); int ziyaretSayisiHaftalik = 0; int urunSatisToplam = 0; int urunSatisHaftalik = 0; int uyeKayitSayisiHaftalik = 0; int haftaBaslangic = 0; int haftaBitis = 0; //Toplam kayıtlar var ziyaretciSayisi = db.istatistik.Count(); var urunSatinAlmaSayisi = db.satinAlmaGecmis; urunSatisToplam += (from m in db.satinAlmaGecmis select m.Adet).DefaultIfEmpty(0).Sum(); var uyeKayitSayisiToplam = db.kullanici.Count(); //Tarih İşlemleri var tarihGun = DateTime.Now.Day; var tarihHafta = DateTime.Now.DayOfWeek; System.Collections.ArrayList liste = new System.Collections.ArrayList(); for (int i = 0; i < 7; i++) { if (tarihHafta.ToString() == "Monday") { liste.Add("Monday"); haftaBaslangic = DateTime.Now.Day; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Tuesday") { liste.Add("Monday"); liste.Add("Tuesday"); haftaBaslangic = DateTime.Now.Day - 1; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Wednesday") { liste.Add("Monday"); liste.Add("Tuesday"); liste.Add("Wednesday"); haftaBaslangic = DateTime.Now.Day - 2; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Thursday") { liste.Add("Monday"); liste.Add("Tuesday"); liste.Add("Wednesday"); liste.Add("Thursday"); haftaBaslangic = DateTime.Now.Day - 3; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Friday") { liste.Add("Monday"); liste.Add("Tuesday"); liste.Add("Wednesday"); liste.Add("Thursday"); liste.Add("Friday"); haftaBaslangic = DateTime.Now.Day - 4; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Saturday") { liste.Add("Monday"); liste.Add("Tuesday"); liste.Add("Wednesday"); liste.Add("Thursday"); liste.Add("Friday"); liste.Add("Saturday"); haftaBaslangic = DateTime.Now.Day - 5; haftaBitis = haftaBaslangic + 7; break; } else if (tarihHafta.ToString() == "Sunday") { liste.Add("Monday"); liste.Add("Tuesday"); liste.Add("Wednesday"); liste.Add("Thursday"); liste.Add("Friday"); liste.Add("Saturday"); liste.Add("Sunday"); haftaBaslangic = DateTime.Now.Day - 6; haftaBitis = haftaBaslangic + 7; break; } } //Günlük Kayıtlar var ziyaretSayisiGunluk = db.istatistik.Where(x => x.ziyaretTarih.Day == DateTime.Now.Day).Count(); var urunSayisiGunluk = db.satinAlmaGecmis.Where(x => x.satinAlmaTarih.Day == DateTime.Now.Day).Count(); var uyeKayitSayisiGünlük = db.kullanici.Where(x => x.memberSince.Day == DateTime.Now.Day).Count(); //Haftalık kayıtlar foreach (var item in liste) { var query1 = (from m in db.istatistik select m).AsEnumerable(); ziyaretSayisiHaftalik += (from m in query1 where (m.ziyaretTarih.DayOfWeek.ToString() == item.ToString()) && (m.ziyaretTarih.Month == DateTime.Now.Month) && (m.ziyaretTarih.Day <= haftaBitis - 1 && m.ziyaretTarih.Day >= haftaBaslangic) select m).Count(); var query2 = (from m in db.satinAlmaGecmis select m).AsEnumerable(); urunSatisHaftalik += (from m in query2 where (m.satinAlmaTarih.DayOfWeek.ToString() == item.ToString()) && (m.satinAlmaTarih.Month == DateTime.Now.Month) && (m.satinAlmaTarih.Day <= haftaBitis - 1 && m.satinAlmaTarih.Day >= haftaBaslangic) select m).Count(); var query3 = (from m in db.kullanici select m).AsEnumerable(); uyeKayitSayisiHaftalik += (from m in query3 where (m.memberSince.DayOfWeek.ToString() == item.ToString()) && (m.memberSince.Month == DateTime.Now.Month) && (m.memberSince.Day <= haftaBitis - 1 && m.memberSince.Day >= haftaBaslangic) select m).Count(); } //En çok 5 liler var urunler = db.urunler.GroupBy(x => x.satisAdet).ToList(); var sepetUrunler = db.urunler.GroupBy(x => x.sepetAdet).ToList(); foreach (var item in sepetUrunler) { model.enCokSepetUrun.Add(item.FirstOrDefault().urunAd); } foreach (var item in urunler) { model.enCokSatisUrun.Add(item.FirstOrDefault().urunAd); } model.enCokSepetUrun.Reverse(); if (model.enCokSepetUrun.Count < 5) { model.enCokSepetUrun.RemoveAt(model.enCokSepetUrun.Count - 1); } model.enCokSatisUrun.Reverse(); if (model.enCokSatisUrun.Count < 5) { model.enCokSatisUrun.RemoveAt(model.enCokSatisUrun.Count - 1); } //en çok satış yapan kategori List <int> list = new List <int>(); foreach (var item in db.kategoriler) { var kategori = (from m in db.urunler where m.kategoriID.kategoriID == item.kategoriID select m.satisAdet).DefaultIfEmpty(0).Sum(); list.Add(kategori); } int kategorimax = list.Max(); int a = list.IndexOf(kategorimax); foreach (var item in db.kategoriler) { var urun = (from m in db.urunler where m.kategoriID.kategoriID == item.kategoriID select m.satisAdet).DefaultIfEmpty(0).Sum(); if ((a + 1) == item.kategoriID) { if (urun > 0) { model.enCokSatisKategori = item.kategoriAd; } } } //modeli sayfaya yollama kısmı model.ziyaretSayisiHaftalik = ziyaretSayisiHaftalik; model.ziyaretSayisiGünlük = ziyaretSayisiGunluk; model.ziyaretSayisiToplam = ziyaretciSayisi; model.urunSayisiToplam = urunSatisToplam; model.urunSayisiGünlük = urunSayisiGunluk; model.urunSayisiHaftalik = urunSatisHaftalik; model.uyeKayitSayisiGünlük = uyeKayitSayisiGünlük; model.uyeKayitSayisiHaftalik = uyeKayitSayisiHaftalik; model.uyeKayitSayisiToplam = uyeKayitSayisiToplam; model.admin = db.admin.FirstOrDefault(); return(View(model)); }
public ActionResult SendSuggestion(HomePageModel model) { SaveSuggestion(model.Email, model.UserName, model.Body); return(RedirectToAction("Index", "Home")); }
public async Task <HomePageModel> Get() { HomePageModel model = new HomePageModel(); //model.Message = _db.HomePageMessage.FirstOrDefault(); model.Message = string.Empty; NoteFile hpmf = _db.NoteFile.Where(p => p.NoteFileName == "homepagemessages").FirstOrDefault(); if (hpmf != null) { NoteHeader hpmh = _db.NoteHeader.Where(p => p.NoteFileId == hpmf.Id).OrderByDescending(p => p.CreateDate).FirstOrDefault(); if (hpmh != null) { model.Message = _db.NoteContent.Where(p => p.NoteHeaderId == hpmh.Id).FirstOrDefault().NoteBody; } } model.NoteFiles = _db.NoteFile .OrderBy(p => p.NoteFileName).ToList(); model.NoteAccesses = new List <NoteAccess>(); List <UserData> udl = _db.UserData.ToList(); foreach (NoteFile nf in model.NoteFiles) { UserData ud = udl.Find(p => p.UserId == nf.OwnerId); ud.MyGuid = ""; ud.MyStyle = ""; nf.Owner = ud; } try { string userName = this.HttpContext.User.FindFirst(ClaimTypes.Name).Value; if (!string.IsNullOrEmpty(userName)) { IdentityUser user = await _userManager.FindByNameAsync(userName); model.UserData = _db.UserData.Single(p => p.UserId == user.Id); foreach (NoteFile nf in model.NoteFiles) { NoteAccess na = await AccessManager.GetAccess(_db, user.Id, nf.Id, 0); model.NoteAccesses.Add(na); } if (model.NoteAccesses.Count > 0) { NoteFile[] theList = new NoteFile[model.NoteFiles.Count]; model.NoteFiles.CopyTo(theList); foreach (NoteFile nf2 in theList) { NoteAccess na = model.NoteAccesses.SingleOrDefault(p => p.NoteFileId == nf2.Id); if (!na.ReadAccess && !na.Write && !na.EditAccess) { model.NoteFiles.Remove(nf2); } } } } else { model.UserData = new UserData { TimeZoneID = Globals.TimeZoneDefaultID }; } } catch { model.UserData = new UserData { TimeZoneID = Globals.TimeZoneDefaultID }; } //model.TimeZone = _db.TZone.Single(p => p.Id == model.UserData.TimeZoneID); Globals.GuestId = model.GuestId = "*none*"; UserData Gdata = _db.UserData.Where(p => p.DisplayName == "Guest").FirstOrDefault(); if (Gdata != null) { Globals.GuestId = model.GuestId = Gdata.UserId; IdentityUser me = await _userManager.FindByIdAsync(Globals.GuestId); model.GuestEmail = Globals.GuestEmail = me.Email; } return(model); }
public ActionResult ProductDetails(int?urunid, string text, string addCart, string addFavorites, string btnSil, string btnLogin, string btnLogout, string eposta, string sifre) { DatabaseContext db = new DatabaseContext(); HomePageModel model = new HomePageModel(); var kullaniciID = Convert.ToInt32(Session["kullaniciID"]); var kategoriUrun = (from m in db.urunler where m.urunID == urunid select m).First(); if (btnLogin != null) { var kullanici = (from m in db.kullanici where m.email == eposta && m.kullaniciSifre == sifre select m).FirstOrDefault(); var ziyaretciSepetList = (from m in db.sepet where m.kullaniciID == null select m).ToList(); try { Session["kullaniciID"] = kullanici.kullaniciID; Session["kullaniciAd"] = kullanici.kullaniciAd; Session["kullaniciSoyAd"] = kullanici.kullaniciSoyAd; Session["kullaniciemail"] = kullanici.email; Session["kullaniciSifre"] = kullanici.kullaniciSifre; Session["kullaniciAdres"] = kullanici.Adres; Session["kullaniciUlke"] = kullanici.Country; Session["kullaniciUyelikTarihi"] = kullanici.memberSince; Session["loginDurum"] = 1; Session["sepetAdet"] = 0; kullaniciID = Convert.ToInt32(Session["kullaniciID"]); model.urunler = db.urunler.ToList(); //select * from urunler } catch (Exception) { //TODO BU KULLANICI BULUNAMADI. model.urunler = db.urunler.ToList(); ViewData["alertLogin"] = "******"; var fullUrl = this.Url.Action("ProductDetails", "Product", new { urunid = urunid }); return(Redirect(fullUrl)); } foreach (var item in ziyaretciSepetList) { int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet == 0) { item.kullaniciID = (from m in db.kullanici where m.kullaniciID == kullaniciID select m).FirstOrDefault(); db.sepet.Add(item); db.SaveChanges(); } else { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m).FirstOrDefault(); sepetGüncelle.urunAdet += item.urunAdet; db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); //last } model.urunler = db.urunler.ToList(); //select * from urunler model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } else if (btnLogout != null) { Session["loginDurum"] = 0; model.urunler = db.urunler.ToList(); model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); Response.Clear(); Response.BufferOutput = true; } if (btnSil != null) { model.kategoriler = db.kategoriler.ToList(); model.seciliUrun = null; model.seciliUrun = kategoriUrun; if (Convert.ToInt32(Session["loginDurum"]) == 1) { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } //ZİYATETÇİ else { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); } } ViewData["hide"] = "none"; if (addCart != null) { Sepet sepet = new Sepet(); sepet.urunID = (from m in db.urunler where m.urunID == urunid select m).FirstOrDefault(); sepet.urunAdet = 1; model.kategoriler = db.kategoriler.ToList(); model.seciliUrun = kategoriUrun; model.seciliUrun.sepetAdet++; db.SaveChanges(); //ZİYARETÇİYSE if (Convert.ToInt32(Session["loginDurum"]) != 1) { Session["sepetAdetZiyaretci"] = (from m in db.sepet where m.kullaniciID == null select m.urunAdet).DefaultIfEmpty(0).Sum(); var eklendiMi = (from m in db.sepet where m.urunID.urunID == urunid && m.kullaniciID == null select m).FirstOrDefault(); if (eklendiMi == null) { try { sepet.kullaniciID = (from m in db.kullanici where m == null select m).FirstOrDefault(); db.sepet.Add(sepet); db.SaveChanges(); model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Session["sepetAdetZiyaretci"] = Convert.ToInt32(Session["sepetAdetZiyaretci"]) + 1; } catch (Exception) { throw; } } else { var sepetGüncelle = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == urunid select m).FirstOrDefault(); sepetGüncelle.urunAdet++; db.SaveChanges(); if (db.sepet.Where(x => x.kullaniciID == null) == null) { model.sepet = null; } else { model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); } Session["sepetAdetZiyaretci"] = Convert.ToInt32(Session["sepetAdetZiyaretci"]) + 1; } Response.Redirect(Request.RawUrl); } //KULLANICIYSA else if (Convert.ToInt32(Session["loginDurum"]) == 1) { Session["sepetAdetKullanici"] = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID select m.urunAdet).DefaultIfEmpty(0).Sum(); var eklendiMi = (from m in db.sepet where m.urunID.urunID == urunid && m.kullaniciID.kullaniciID == kullaniciID select m).FirstOrDefault(); if (eklendiMi == null) { try { sepet.kullaniciID = (from m in db.kullanici where m.kullaniciID == kullaniciID select m).FirstOrDefault(); db.sepet.Add(sepet); db.SaveChanges(); model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Session["sepetAdetKullanici"] = Convert.ToInt32(Session["sepetAdetKullanici"]) + 1; } catch (Exception) { throw; } } else { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == urunid select m).FirstOrDefault(); sepetGüncelle.urunAdet++; db.SaveChanges(); if (db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID) == null) { model.sepet = null; } else { model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); } Session["sepetAdetKullanici"] = Convert.ToInt32(Session["sepetAdetKullanici"]) + 1; } Response.Redirect(Request.RawUrl); } } if (addFavorites != null) { Favorites f = new Favorites(); var sayi = 0; sayi = (int)Session["kullaniciID"]; f.urunID = kategoriUrun; var kullanici = (from m in db.kullanici where m.kullaniciID == sayi select m).FirstOrDefault(); f.kullaniciID = kullanici; db.favorites.Add(f); db.SaveChanges(); model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); } model.kategoriler = db.kategoriler.ToList(); model.seciliUrun = null; model.seciliUrun = kategoriUrun; Session["sepetAdetKullanici"] = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID select m.urunAdet).DefaultIfEmpty(0).Sum(); Session["sepetAdetZiyaretci"] = (from m in db.sepet where m.kullaniciID == null select m.urunAdet).DefaultIfEmpty(0).Sum(); return(View("ProductDetails", model)); }
[HttpGet] //API TO GET HOMEPAGE DASHBOARD COUNTS (ADMIN HOMEPAGE) public List <HomePageModel> GetHomePage() { List <HomePageModel> GeneralHomePageDataList = new List <HomePageModel>(); try { List <DatasetSubcategoryMapping> model = new List <DatasetSubcategoryMapping>(); model = _CLRCP_MASTERContext.DatasetSubcategoryMapping.ToList(); int sourceDbCount = 0; int destinationDbCount = 0; int valDestinationDbCount = 0; //foreach to fetch overall source and destination counts per dataset //for eg: ASR source count:2 destination count: 15 foreach (var item in model) { HomePageModel homePageCount = new HomePageModel(); destinationDbCount = 0; sourceDbCount = 0; valDestinationDbCount = 0; string DatasetName = Convert.ToString(_CLRCP_MASTERContext.Datasets.Where(e => e.DatasetId == item.DatasetId).Select(e => e.Name).FirstOrDefault()) ?? ""; string SourceDB = Convert.ToString(_CLRCP_MASTERContext.SubCategories.Where(e => e.SubcategoryId == item.SourceSubcategoryId).Select(e => e.Name).FirstOrDefault()) ?? ""; string DestinationDB = Convert.ToString(_CLRCP_MASTERContext.SubCategories.Where(e => e.SubcategoryId == item.DestinationSubcategoryId).Select(e => e.Name).FirstOrDefault()) ?? ""; if (SourceDB == "Text") { sourceDbCount = _TEXTContext.Text.Where(e => e.DatasetId == item.DatasetId).Count(); if (DestinationDB == "TextSpeech") { destinationDbCount = _TextToSpeechContext.TextSpeech.Where(e => e.DatasetId == item.DatasetId).Count(); //List<long> textSpeeches = _textToSpeechContext.TextSpeech.Where(e => e.DatasetId == item.DatasetId).Select(x=>x.AutoId).ToList(); //valDestinationDbCount= _VALIDATION_INFOContext.TextspeechValidationResponseDetail.Where(e => textSpeeches.Contains(e.RefAutoid)).Count(); List <long> UserValData = _VALIDATION_INFOContext.TextspeechValidationResponseDetail.Select(X => X.RefAutoid).ToList(); List <long> textSpeeches = _TextToSpeechContext.TextSpeech.Where(x => x.DatasetId == item.DatasetId).Select(e => e.AutoId).ToList(); valDestinationDbCount = UserValData.Intersect(textSpeeches).Count(); } else if (DestinationDB == "TextText") { destinationDbCount = _TextToTextContext.TextText.Where(e => e.DatasetId == item.DatasetId).Count(); //List<long> textTextes = _textToTextContext.TextText.Where(e => e.DatasetId == item.DatasetId).Select(x => x.AutoId).ToList(); //valDestinationDbCount += _VALIDATION_INFOContext.TexttextValidationResponseDetail.Where(e => textTextes.Contains(e.RefAutoid)).Count(); List <long> UserValData = _VALIDATION_INFOContext.TexttextValidationResponseDetail.Select(X => X.RefAutoid).ToList(); List <long> texttexts = _TextToTextContext.TextText.Where(x => x.DatasetId == item.DatasetId).Select(e => e.AutoId).ToList(); valDestinationDbCount = UserValData.Intersect(texttexts).Count(); } } if (SourceDB == "Images") { sourceDbCount = _IMAGEContext.Images.Where(e => e.DatasetId == item.DatasetId).Count(); if (DestinationDB == "ImageText") { destinationDbCount = _ImageToTextContext.ImageText.Where(e => e.DatasetId == item.DatasetId).Count(); //List<long> imageTextes = _imageToTextContext.ImageText.Where(e => e.DatasetId == item.DatasetId).Select(x => x.AutoId).ToList(); //valDestinationDbCount = _VALIDATION_INFOContext.ImagetextValidationResponseDetail.Where(e => imageTextes.Contains(e.RefAutoid)).Count(); List <long> UserValData = _VALIDATION_INFOContext.TexttextValidationResponseDetail.Select(X => X.RefAutoid).ToList(); List <long> texttexts = _TextToTextContext.TextText.Where(x => x.DatasetId == item.DatasetId).Select(e => e.AutoId).ToList(); valDestinationDbCount = UserValData.Intersect(texttexts).Count(); } } homePageCount.DataSetName = DatasetName; homePageCount.SourceDataCount = sourceDbCount; homePageCount.CollectedDataCount = destinationDbCount; homePageCount.ValidatedDataCount = valDestinationDbCount; GeneralHomePageDataList.Add(homePageCount); } return(GeneralHomePageDataList); } catch (Exception) { return(null); //return BadRequest(new { message = ex.Message }); } }
public ActionResult ProductGridKategori(string btnSil, string txtKeyword, decimal?minPrice, decimal?maxPrice, int?kategoriID, string eposta, string sifre, string btnLogin, string btnLogout, string btnSearch, string btnPriceRange) { DatabaseContext db = new DatabaseContext(); HomePageModel model = new HomePageModel(); var kullaniciID = Convert.ToInt32(Session["kullaniciID"]); var kategoriUrun = (from m in db.urunler where m.kategoriID.kategoriID == kategoriID select m).ToList(); if (btnLogin != null) { var kullanici = (from m in db.kullanici where m.email == eposta && m.kullaniciSifre == sifre select m).FirstOrDefault(); try { Session["kullaniciID"] = kullanici.kullaniciID; Session["kullaniciAd"] = kullanici.kullaniciAd; Session["kullaniciSoyAd"] = kullanici.kullaniciSoyAd; Session["kullaniciemail"] = kullanici.email; Session["kullaniciSifre"] = kullanici.kullaniciSifre; Session["kullaniciAdres"] = kullanici.Adres; Session["kullaniciUlke"] = kullanici.Country; Session["kullaniciUyelikTarihi"] = kullanici.memberSince; Session["loginDurum"] = 1; Session["sepetAdet"] = 0; kullaniciID = Convert.ToInt32(Session["kullaniciID"]); model.urunler = db.urunler.ToList(); //select * from urunler } catch (Exception) { //TODO BU KULLANICI BULUNAMADI. model.urunler = db.urunler.ToList(); ViewData["alertLogin"] = "******"; Session["kategoriID"] = kategoriID; var fullUrl = this.Url.Action("ProductGridKategori", "Product", new { kategoriID = kategoriID }); return(Redirect(fullUrl)); } kullaniciID = Convert.ToInt32(Session["kullaniciID"]); var ziyaretciSepetList = (from m in db.sepet where m.kullaniciID == null select m).ToList(); foreach (var item in ziyaretciSepetList) { int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet == 0) { item.kullaniciID = (from m in db.kullanici where m.kullaniciID == kullaniciID select m).FirstOrDefault(); db.sepet.Add(item); db.SaveChanges(); } else { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == item.urunID.urunID select m).FirstOrDefault(); sepetGüncelle.urunAdet += item.urunAdet; db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); //last } model.urunler = db.urunler.ToList(); //select * from urunler model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } else if (btnLogout != null) { Session["loginDurum"] = 0; model.urunler = db.urunler.ToList(); model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); } else if (btnSil != null) { model.kategoriler = db.kategoriler.ToList(); TempData["kategoriID"] = kategoriID; ViewData["kategoriID"] = kategoriID; model.urunler = kategoriUrun; if (Convert.ToInt32(Session["loginDurum"]) == 1) { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } //ZİYATETÇİ else { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); } } else if (btnPriceRange != null) { if (Convert.ToInt32(Session["loginDurum"]) == 1) { model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); } else { model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); } if (minPrice < maxPrice) { var kategoriUrunFiyat = (from m in db.urunler where m.kategoriID.kategoriID == kategoriID && (m.urunFiyat - (m.urunFiyat * m.indirimYuzde / 100)) >= minPrice && (m.urunFiyat - (m.urunFiyat * m.indirimYuzde / 100)) <= maxPrice select m).ToList(); model.urunler = kategoriUrunFiyat; } } else if (btnSearch != null) { var aramaUrun = (from m in db.urunler where m.urunAd.Contains(txtKeyword) select m).ToList(); model.urunler = aramaUrun; if (Convert.ToInt32(Session["loginDurum"]) == 1) { model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); } else { model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); } } model.kategoriler = db.kategoriler.ToList(); return(View("ProductGrid", model)); }
protected override void OnTestRunInitialize() { Target = new HomePageModel(); this.Target.Navigate(); }
public void TestLogin(List <TestCaseModel> testCaseModels) { HomePageModel home = LoginPageModel.TestLogin(testCaseModels); }
public ActionResult ProfilePage(string btnLogout, string btnSil) { DatabaseContext db = new DatabaseContext(); HomePageModel model = new HomePageModel(); var kullaniciID = Convert.ToInt32(Session["kullaniciID"]); model.satinAlmaGecmis = db.satinAlmaGecmis.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); if (btnLogout != null) { Session["loginDurum"] = 0; model.urunler = db.urunler.ToList(); model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); return(RedirectToAction("Index", "Home")); } if (btnSil != null) { model.kategoriler = db.kategoriler.ToList(); model.urunler = db.urunler.ToList(); if (Convert.ToInt32(Session["loginDurum"]) == 1) { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID.kullaniciID == kullaniciID).ToList(); Response.Redirect(Request.RawUrl); } //ZİYATETÇİ else { int btnSilint = Convert.ToInt32(btnSil); int adet = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m.urunAdet).DefaultIfEmpty(0).Sum(); if (adet > 1) { var sepetGüncelle = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); sepetGüncelle.urunAdet--; db.SaveChanges(); } else { Sepet sepetvol1 = (from m in db.sepet where m.kullaniciID == null && m.urunID.urunID == btnSilint select m).FirstOrDefault(); db.sepet.Remove(sepetvol1); db.SaveChanges(); } model.sepet = db.sepet.Where(x => x.kullaniciID == null).ToList(); Response.Redirect(Request.RawUrl); } } Session["sepetAdetKullanici"] = (from m in db.sepet where m.kullaniciID.kullaniciID == kullaniciID select m.urunAdet).DefaultIfEmpty(0).Sum(); Session["sepetAdetZiyaretci"] = (from m in db.sepet where m.kullaniciID == null select m.urunAdet).DefaultIfEmpty(0).Sum(); model.kategoriler = db.kategoriler.ToList(); //select * from kategoriler model.favorites = db.favorites.ToList(); return(View(model)); }