public AllViewModel <NewsSummaryViewModel> All(AllViewModel <NewsSummaryViewModel> model) { var news = this._newsRepository.All(); if (!string.IsNullOrEmpty(model.Author)) { news = news .OrderByDescending(p => p.CreatedOn) .Where(p => p.Author.UserName == model.Author); } else { news = news .OrderByDescending(p => p.CreatedOn); } var currentNews = news .Skip((model.CurrentPage - 1) * model.PageSize) .Take(model.PageSize) .To <NewsSummaryViewModel>() .ToList(); var totalNews = news.Count(); model.TotalPages = (int)Math.Ceiling(totalNews / (double)model.PageSize); model.Entities = currentNews; return(model); }
public AllViewModel GetAllViewModel(string filter, User currentUser) { AllViewModel allViewModel = new AllViewModel(); if (string.IsNullOrEmpty(filter) || filter == "all") { IEnumerable <GamesViewModel> games = this.Context.Games.Select(g => new GamesViewModel() { Id = g.Id, Description = g.Description.Substring(0, 300), ImageThumbnail = g.ImageThumbnail, Price = g.Price, Size = g.Size, Title = g.Title }); allViewModel.Games = games; } else { IEnumerable <GamesViewModel> games = currentUser.Games.Select(g => new GamesViewModel() { Id = g.Id, Description = g.Description.Substring(0, 300), ImageThumbnail = g.ImageThumbnail, Price = g.Price, Size = g.Size, Title = g.Title }); allViewModel.Games = games; } return(allViewModel); }
public IActionResult Index() { AllViewModel model = new AllViewModel(); model.hardwares = _hardwareRepository.AllHardware(); return(View(model)); }
public IHttpResponse Search(IssueSearchInputModel model) { var name = model.Name; var statusValues = Enum.GetValues(typeof(Status)); var resultData = this.Db.Issues .Where(i => i.Name.Contains(name)).ToList(); if (model.Status != "All") { var status = (Status)Enum.Parse(typeof(Status), model.Status); resultData = this.Db.Issues .Where(i => i.Status == status && i.Name.Contains(name)).ToList(); } var searchResult = resultData .Select(i => new IssueViewModel() { Id = i.Id, Name = i.Name, Status = i.Status.ToString(), Priority = i.Priority.ToString(), CreationDate = i.CreationDate.ToShortDateString(), Author = i.User.Username, }).ToList(); var modelView = new AllViewModel() { Issues = searchResult, StatusValues = statusValues, }; return(this.View("/Issues/All", modelView)); }
public IActionResult All() { var postModels = _dataStore.GetAllPosts(); postModels.AddRange(_dataStore.GetAllDrafts()); var viewModel = new AllViewModel { AllSummaries = new List <AllSummaryModel>() }; if (!postModels.Any()) { return(View(viewModel)); } foreach (var post in postModels) { viewModel.AllSummaries.Add(new AllSummaryModel { Id = post.Id, Title = post.Title, CommentCount = post.Comments.Count, PublishTime = post.PubDate, IsDeleted = post.IsDeleted, IsPublic = post.IsPublic }); } return(View(viewModel)); }
public ActionResult CommonAd(string currentTab, string researchType, string operation) { AllViewModel allViewModel = new AllViewModel(); allViewModel.PeopleSearchingVM = new PeopleSearchingViewModel(true); PeopleSearchingViewModel peopleSearching = new PeopleSearchingViewModel(true); for (int i = 0; i < 6; i++) { peopleSearching.IdPeopleSearching = i; allViewModel.PeopleSearchingVM.LstPeopleSearchingVM.Add(peopleSearching); } if (currentTab != null && currentTab.Length != 0) { ViewData["currentTab"] = currentTab; } else { ViewData["currentTab"] = "AnnonceLocation"; } ViewData["researchType"] = (researchType != null) ? researchType : "searching"; ViewData["operation"] = (operation != null) ? operation : "operation"; return(View("~/Views/Ad_Common/RubriqueAd.cshtml", allViewModel)); }
public ActionResult Connection(AllViewModel AllViewModel) { if (ModelState.IsValid) { //FormsAuthentication.SetAuthCookie("User", true); AllViewModel.AccountVM.UserBo.IdUser = WebSecurity.GetUserId(AllViewModel.AccountVM.UserBo.UserName); if (AllViewModel.AccountVM.UserBo.IdUser != 0) { string username = "******"; bool isPersistent = false; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, "User", DateTime.Now, DateTime.Now.AddMinutes(30), isPersistent, Convert.ToString(AllViewModel.AccountVM.UserBo.IdUser), FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); // Redirect back to original URL. return(Redirect(FormsAuthentication.GetRedirectUrl(username, isPersistent))); } } return(PartialView("~/Views/Account/ModalAccount.cshtml", new AllViewModel())); }
public void NewsServiceGetAllNewsWithAuthor() { //Arrange var newsRepository = new Mock <IDeletableEntityRepository <News> >(); newsRepository.Setup(r => r.All()).Returns(this.NewsData); this.Service = new NewsService(newsRepository.Object, null, null); //Act var authorName = this.NewsData.First().Author.UserName; var expectedNewsCount = this.NewsData.Count(n => n.Author.UserName == authorName); var model = new AllViewModel <NewsSummaryViewModel> { Author = authorName }; var news = this.Service.All(model); //Assert Assert.That(news.Entities.All(p => p.Author == model.Author)); Assert.That(news.Entities.Count <= model.PageSize); Assert.AreEqual( news.TotalPages, (int)Math.Ceiling(expectedNewsCount / (double)model.PageSize), message: $"TotalPages: {news.TotalPages} - Entities: {news.Entities.Count} - User {authorName}"); Assert.That(news.Entities, Is.All.InstanceOf <NewsSummaryViewModel>()); }
// GET: Section public ActionResult Index() { AllViewModel model = new AllViewModel(); model.Categories = db.Categories.ToList(); return(View(model)); }
public IActionResult Index() { AllViewModel model = new AllViewModel(); model.books = _bookRepository.AllBook(); return(View(model)); }
public ActionResult ModalCreateEmptyAccount() { AllViewModel allVM = new AllViewModel(); allVM.AccountVM = new AccountViewModel(true); return(PartialView(allVM)); }
public IActionResult <AllViewModel> All(HttpSession session, HttpResponse response) { User activeUser = this.GetAuthenticatedUser(response, session); AllViewModel viewModel = this.service.GetAllViewModel(activeUser); return(this.View(viewModel)); }
public IActionResult All(AllViewModel <PostSummaryViewModel> model) { model.PageSize = int.Parse(this._settingsService.Get(GlobalConstants.AllEntitiesPageSizeKey)); model = this._blogService.All(model); return(View(model)); }
public IActionResult All() { AllViewModel model = new AllViewModel(); model.books = _bookRepository.AllBook(); model.hardwares = _hardwareRepository.AllHardware(); model.softwares = _softwareRepository.AllSoftware(); return(View(model)); }
public IActionResult Index() { var viewModel = new AllViewModel { All = this.authorsService.GetAll <AuthorAllViewModel>(), }; return(this.View(viewModel)); }
public IActionResult Index() { var viewModel = new AllViewModel { All = this.categoriesService.GetAll <CategoryAllViewModel>(), }; return(this.View(viewModel)); }
public async Task <ActionResult> AddMovie() { IChannelService ics = new ChannelService(); var list = await ics.ReturnChannelServices(); AllViewModel allvm = new AllViewModel(list); return(View(allvm)); }
public ActionResult AddMoviePost(AllViewModel allvm) { IMovieService ims = new MovieService(); allvm.AvailableAmount = allvm.Amount; allvm.ChannelID = Int32.Parse(Request.Form.Get("select")); ims.SaveMovieService(allvm); return(RedirectToAction("Index")); }
public IActionResult All() { var model = new AllViewModel { Expenses = this.expenseService.GetAll <ExpenseViewModel>(), }; return(this.View(model)); }
public IActionResult All() { var categories = this.categoryService .GetAllCategories <CategoryViewModel>(); var model = new AllViewModel { Categories = categories, }; return(this.View(model)); }
public async Task <IActionResult> Old() { var user = await this.userManager.GetUserAsync(this.User); var oldHomeworks = this.homeworksService.GetAllHomeworks().Where(x => x.UserId == user.Id && x.IsReady == true); var viewModel = new AllViewModel { Homeworks = oldHomeworks, }; return(this.View(viewModel)); }
public ActionResult All() { AllViewModel vm = new AllViewModel(); using (TodoContext db = new TodoContext()) { var AllTodos = db.Todos.OrderBy(x => x.CreateTime); vm.AllList = AllTodos.ToList();//全部Todo vm.NotCompleteCount = AllTodos.Where(x => x.IsComplete == false).Count(); } return(View(vm)); }
public async Task <IActionResult> All() { var user = await this.userManager.GetUserAsync(this.User); var exercise = this.exercisesService.GetAllExercise().Where(x => x.UserId == user.Id); var viewModel = new AllViewModel { Exercises = exercise, }; return(this.View(viewModel)); }
public ActionResult AddUpd_ModalRentalAd(string operation) { if (operation != null) { ViewData["operation"] = operation; } ViewData["targetCity"] = "Rennes"; AllViewModel AllViewModel = new AllViewModel(); return(PartialView(AllViewModel)); }
public ActionResult HtmlAnnoncePeople() { AllViewModel allVM = new AllViewModel(); allVM.PeopleSearchingVM = new PeopleSearchingViewModel(true); Random rnd = new Random(); int id = rnd.Next(100, 200); allVM.PeopleSearchingVM.IdPeopleSearching = id; return(PartialView(allVM)); }
public AllViewModel GetDataUser() { int idUser = new AccountController().GetIdUserFromCookieConnection(HttpContext); PersonBo personBo = personManager.GetByUserId(idUser); AllViewModel allViewModel = new AllViewModel(); allViewModel.PeopleSearchingVM = new PeopleSearchingViewModel(); allViewModel.PeopleSearchingVM.ResearchRoommateBo = researchRoommateManager.GetByPersonId(personBo.IdPerson); allViewModel.PeopleSearchingVM.LstPlaceBo = placeManager.GetByResearchRoommateId(allViewModel.PeopleSearchingVM.ResearchRoommateBo.IdResearchRoommate); return(allViewModel); }
public void SaveMovieService(AllViewModel allvm) { try { Movie movie = new Movie(); AutoMapper.Mapper.Map(allvm, movie); db.Movies.Add(movie); db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
public async Task <IActionResult> Update(AllViewModel model) { if (ModelState.IsValid) { User user = await db.Users.FirstOrDefaultAsync(u => u.email == CurrentUser.currentuser.email); user.password = model.pass.password; db.Update(user); db.SaveChanges(); ViewBag.Pass = "******"; } ViewBag.Collections = GetGPX(); return(View("Room")); }
public async Task <IActionResult> Old(int?page = 1) { var user = await this.userManager.GetUserAsync(this.User); var allCourses = this.coursesService.GetAllOldCourses(user.Id, RecordsPerPage, (int)((page - 1) * RecordsPerPage)); var viewModel = new AllViewModel { Courses = allCourses.Where(x => x.Grade.HasValue), CurrentPage = (int)page, }; var count = this.coursesService.GetOldCoursesCount(user.Id); viewModel.PagesCount = (int)Math.Ceiling((double)count / RecordsPerPage); return(this.View(viewModel)); }
public AllViewModel GetAllViewModel(User activeUser) { AllViewModel view = new AllViewModel(); IEnumerable <AllCategoryViewModel> categories = this.Context.Categories.Entities .Select(category => new AllCategoryViewModel() { Id = category.Id, CategoryName = category.Name }); view.Categories = categories; return(view); }