public IActionResult UpdateEntry(EntryDetailsViewModel _entry, int _entryId, string _updatedHeadline, string _updatedText) { if (ModelState.IsValid) { if ((_updatedHeadline.Length > 0 && _updatedHeadline.Length <= 50) && (_updatedText.Length > 0 && _updatedText.Length <= 2000)) { var entry = _context.Entries.SingleOrDefault(eid => eid.EntryId == _entryId); entry.Headline = _updatedHeadline; entry.Text = _updatedText; _context.Entries.Update(entry); _context.SaveChanges(); return(RedirectToAction("EntryDetails", new { _entryId = _entryId })); } else { TempData["Error"] = "Titlen måste vara mellan 1-50 tecken och texten mellan 1-2000 tecken."; } } return(RedirectToAction("EntryDetails", new { _entryId = _entryId })); }
public EntryDetailsPage() { BindingContextChanged += (sender, args) => { if (_vm == null) { return; } _vm.PropertyChanged += (s, e) => { if (e.PropertyName == "Entry") { UpdateMap(); } }; }; this.SetBinding(TitleProperty, "Entry.Title"); _map = new NoZoomControlsMap { IsShowingUser = true, MapType = MapType.Hybrid }; InitializeComponent(); BindingContext = new EntryDetailsViewModel(DependencyService.Get <INavService>()); MainGrid.Children.Add(_map); Grid.SetRowSpan(_map, 3); _displayDetails(); }
public IActionResult EntryDetails(int _entryId) { EntryDetailsViewModel model = new EntryDetailsViewModel(); model.Entry = _context.Entries.SingleOrDefault(entry => entry.EntryId == _entryId); model.Comments = _context.Comments.Where(comment => comment.EntryId == _entryId).ToList(); model.Categories = _context.Categories.OrderByDescending(x => x.CategoryId == model.Entry.CategoryId).ToList(); model.Entry.CategoryName = _context.Categories.SingleOrDefault(cid => cid.CategoryId == model.Entry.CategoryId).CategoryName; for (int i = 0; i < model.Comments.Count; i++) { model.Comments[i].UserName = _userManager.Users.FirstOrDefault(user => user.Id == model.Comments[i].UserId).UserName; } ViewBag.Error = TempData["Error"]; return(View(model)); }
// Upraví úkol podle dat z entryDetailsSource public SubmitTaskDetailsCommand(EntryDetailsViewModel entryDetailsSource, EntryModel entry) { _entryDetailsSource = entryDetailsSource; _entry = entry; }
// Vytvoří nový úkol podle dat z entryDetailsSource public SubmitTaskDetailsCommand(EntryDetailsViewModel entryDetailsSource) { _entryDetailsSource = entryDetailsSource; }