public ActionResult ById(string id, int?page, int?absolutePageNumber) { var book = this.books.GetById(id); var bookViewModel = AutoMapperConfig.Configuration.CreateMapper().Map <BookReadViewModel>(book); var viewModel = new ReadViewModel(); viewModel.Book = bookViewModel; var allPages = this.pages.GetAllPages(book.Id); var firstPageId = allPages.First().Id; var products = allPages.Select(x => x.HtmlContent); //returns IQueryable<Product> representing an unknown number of products. a thousand maybe? var pageNumber = page ?? 1; // if no page was specified in the querystring, default to the first page (1) var onePageOfProducts = products.ToPagedList(pageNumber, 1); // will only contain 25 products max because of the pageSize if (absolutePageNumber != null) { viewModel.Page = allPages.First(x => x.Id == absolutePageNumber); } else { viewModel.Page = allPages.First(x => x.Id == firstPageId + pageNumber - 1); } this.ViewBag.OnePageOfProducts = onePageOfProducts; return(this.View(viewModel)); }
public async Task <IActionResult> Index(ReadViewModel model) { if (ModelState.IsValid) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await httpClient.GetAsync(new Uri(AppInfos.WebApiUrl) + "/" + model.ID); if (response.IsSuccessStatusCode) { var text = await response.Content.ReadAsStringAsync(); return(View(new ReadViewModel() { Text = text })); } else { return(View(new ReadViewModel() { Error = (int)response.StatusCode })); } } } else { return(View(new ReadViewModel())); } }
/// <summary> /// Gets the inbox from the logged in user /// </summary> /// <param name="userId"></param> /// <returns></returns> public ReadViewModel GetInbox(String userId) { ReadViewModel readViewModel = new ReadViewModel(); readViewModel.UserList = new List <string>(); var messages = messageRepository.GetMessagesToRecipant(userId); readViewModel.NrOfDeleted = 0; readViewModel.NrOfRead = 0; readViewModel.TotNrOfMessages = 0; foreach (var message in messages) { readViewModel.TotNrOfMessages++; var sender = userManager.FindByIdAsync(message.SenderId).GetAwaiter().GetResult().UserName; if (!message.IsDeleted) { if (!readViewModel.UserList.Contains(sender)) { readViewModel.UserList.Add(sender); } if (message.IsRead) { readViewModel.NrOfRead++; } } else { readViewModel.NrOfRead++; readViewModel.NrOfDeleted++; } } return(readViewModel); }
/// <summary> /// Returns the view of the inbox with user that has sent messages to the logged in user /// </summary> /// <returns></returns> // GET: Inbox public async Task <IActionResult> Inbox() { var userId = _userManager.GetUserId(User); ReadViewModel readViewModel = _messageLogic.GetInbox(userId); return(View(readViewModel)); }
public App() { InitializeComponent(); ViewModel = new ReadViewModel(); MainPage = new MainPage(); }
public async Task <IActionResult> Read(int Id) { string userId; CB8_TeamYBD_GroupProject_MVCUser user = new CB8_TeamYBD_GroupProject_MVCUser(); try { userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; user = _context.Users.Find(userId); } catch { userId = ""; } Article article = _context.Articles.Include("Author").First(x => x.Id == Id); CB8_TeamYBD_GroupProject_MVCUser author = article.Author; bool paywall = article.Paid; DateTime dateTime = article.PostDateTime; List <ArticleLike> likes = _context.ArticleLikes.Include("User").Where(x => x.Article == article).ToList(); List <Comment> comments = _context.Comments.Include("User").Where(x => x.Article == article).OrderBy(x => x.CommentDateTime).ToList(); List <CommentLike> commentLikes = _context.CommentLikes.Include("User").Include("Comment").Where(x => x.Comment.Article == article).ToList(); List <CommentResponse> commentResponses = _context.CommentResponses.Include("User").Include("Comment").Where(x => x.Comment.Article == article).OrderBy(x => x.ResponseDateTime).ToList(); List <CommentResponseLike> commentResponseLikes = _context.CommentResponseLikes.Include("User").Include(x => x.Response.Comment).Where(x => x.Response.Comment.Article == article).ToList(); if (paywall == false || ( paywall == true && ( user == author || user.Premium == true || (_context.ArticlePurchases.Where(x => x.Article == article && x.User == user).Count() > 0) || (_context.UserSubcriptions.Where(x => x.Subscriber == user && x.Subscription.User == author && x.EndDate.CompareTo(DateTime.Now) > 0).Count() > 0) ) ) ) { ReadViewModel vm = new ReadViewModel() { UserId = userId, Article = article, Author = author, Likes = likes, Comments = comments, ArticlePostDateTime = dateTime, CommentLikes = commentLikes, CommentResponses = commentResponses, CommentResponseLikes = commentResponseLikes }; return(View(vm)); } else { article.Content = "<h5 style='color: white;'>This article is paid. Please login/register and purchase either this article, a subscription to the author, or a premium ReedMie account.</h5>"; ReadViewModel vm = new ReadViewModel() { UserId = userId, Article = article, Author = author, Likes = likes, Comments = comments, ArticlePostDateTime = dateTime, CommentLikes = commentLikes, CommentResponses = commentResponses, CommentResponseLikes = commentResponseLikes }; return(View(vm)); } }
public ActionResult Read(int id) { var model = new ReadViewModel { Post = PostRepository.Get(id) }; return(View(model)); }
public ReadPage() { InitializeComponent(); BindingContext = readViewModel = new ReadViewModel(this); if (Device.RuntimePlatform == Device.Android) { _navIcon.HeightRequest = 40; } }
public async Task <RepositoryResponse <List <ReadViewModel> > > UpdateInfos([FromBody] List <ReadViewModel> models) { if (models != null) { RemoveCache(); return(await ReadViewModel.UpdateInfosAsync(models)); } else { return(new RepositoryResponse <List <ReadViewModel> >()); } }
public async Task<ActionResult<ReadViewModel>> Save(string culture, [FromBody]ReadViewModel data) { var portalResult = await base.SaveAsync<ReadViewModel>(data, true); if (portalResult.IsSucceed) { return Ok(portalResult); } else { return BadRequest(portalResult); } }
public ActionResult Read(ReadViewModel model) { var comment = new Comment { Post = PostRepository.Get(model.Id), Author = UserRepository.Get(Convert.ToInt32(User.Identity.GetUserId())), Content = model.Content, CreatedAt = DateTime.Now }; CommentRepository.Create(comment); return(RedirectToAction("Read/" + model.Id, "Post")); }
public async Task <RepositoryResponse <ReadViewModel> > Save([FromBody] ReadViewModel model) { if (model != null) { var result = await base.SaveAsync <ReadViewModel>(model, true); return(result); } return(new RepositoryResponse <ReadViewModel>() { Status = 501 }); }
public async Task <IActionResult> Index() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var model = new ReadViewModel(); model.Widgets = await _dbHandler.Read(); ViewData["TIME"] = stopwatch.Elapsed; stopwatch.Stop(); return(View(model)); }
private void OnUpload() { var vm = new ReadViewModel(settings, port, logger); var result = ShowDialog(vm); if (result) { eventAggregator.GetEvent <AddNewFileEvent>().Publish(vm.Memory); ShowDialog(new NotificationReadViewModel()); } if (!result && vm.Exception != null) { ShowDialog(new NotificationErrorViewModel((vm.Exception.InnerException != null) ? vm.Exception.InnerException.Message : vm.Exception.Message)); } RaiseCanExecuteChanged(); }
public IActionResult Read(int houseId, ReadViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var house = _houseService.GetById(houseId, User.Identity.GetId()); if (house != null) { var action = _actionService.GetLastByHouseId(house.Id, Core.Domain.Type.Read); if (model.Endeks <= action.Endeks) { ModelState.AddModelError(string.Empty, "Girdiğiniz endeks, son endeksden büyük olmalıdır."); return(View(model)); } var price = _settingService.GetByChiefId(User.Identity.GetId()).Price; var resultPrice = (model.Endeks - action.Endeks) * price; _actionService.Create(new Core.Domain.Action { Endeks = model.Endeks, Price = resultPrice, Description = model.Description, Type = Core.Domain.Type.Read, CreatedDate = DateTime.Now, HouseId = house.Id }); return(View("Success")); } return(NotFound()); }
public async Task <IActionResult> Read(int id) { try { var article = await this._articleService.GetArticleById(id); var model = new ReadViewModel() { Article = article }; if (article != null) { model.MessageViewModel.Messages.Add("متاسفانه مقاله ای با این شماره یافت نشد"); } return(View(model)); } catch (Exception e) { var model = new IndexViewModel(); model.MessageViewModel.Errors.Add("مشکلی هنگام دریافت اطلاعات رخ داد"); return(RedirectToAction("Index", model)); } }
// // GET: /Blog/Read/$id public virtual ActionResult Read(int id = -1, string slug = "") { var model = new ReadViewModel(); using (var context = new WebsiteContext()) { if (!context.BlogPosts.Any(x => x.BlogPostId == id)) { RedirectToAction("Index", "Blog"); } // eagerly load the tags etc as the context will be disposed var posts = (from t in context.BlogPosts.Include("Tags") where t.BlogPostId == id select t); // get the blog post, but increment the views while we're at it! model.BlogPost = posts.First(); model.BlogPost.Views++; context.SaveChanges(); } return(View(model)); }
private void InitializeViewModel() { _viewModel = AppFactory.GetInstance <ReadViewModel>(); _viewModel.Navigate += ViewModel_Navigate; }
public MainWindow() { InitializeComponent(); ConnectionViewModel vmc = new ConnectionViewModel(portName, serialPortSettings, logger, 12, new DateTime(2015, 06, 14)); connection.DataContext = vmc; ResetViewModel vmr = new ResetViewModel(portName, serialPortSettings, logger); reset.DataContext = vmr; ReadLockViewModel vmrl = new ReadLockViewModel(portName, serialPortSettings, logger, 0x67); readLock.DataContext = vmrl; ReadFuseViewModel vmrf = new ReadFuseViewModel(portName, serialPortSettings, logger, new byte[] { 0x23, 0x56, 0xAF }); readFuse.DataContext = vmrf; HexFileManager hfm = new HexFileManager(); var memory = new Memory(0x40000); hfm.OpenFile("Flash.hex", memory); var memoryEeprom = new Memory(0x1000); hfm.OpenFile("Eeprom.hex", memoryEeprom); EraseViewModel vmref = new EraseViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory); eraseFlash.DataContext = vmref; EraseViewModel vmree = new EraseViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom); eraseEeprom.DataContext = vmree; ReadViewModel vmrrf = new ReadViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory); readFlash.DataContext = vmrrf; ReadViewModel _vmrrf = new ReadViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom); readEeprom.DataContext = _vmrrf; IsEmptyViewModel _vmref = new IsEmptyViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory); isEmptyFlash.DataContext = _vmref; IsEmptyViewModel _vmrre = new IsEmptyViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom); isEmptyEeprom.DataContext = _vmrre; WriteViewModel __vmref = new WriteViewModel(portName, serialPortSettings, logger, MemoryType.FLASH, memory); writeFlash.DataContext = __vmref; WriteViewModel __vmrre = new WriteViewModel(portName, serialPortSettings, logger, MemoryType.EEPROM, memoryEeprom); writeEeprom.DataContext = __vmrre; }
private void Read_Click(object sender, RoutedEventArgs e) { DataContext = new ReadViewModel(); }