public ActionResult EditForm(int?Id = null) { EditFormViewModel context = new EditFormViewModel { Categories = _allCategories.AllCategories.ToList(), News = (Id == null) ? null : _allNews.getObjectNews((int)Id) }; return(View(context)); }
public ActionResult GetItem(int Id) { GetItemViewModel context = new GetItemViewModel(); context.Offset = User.Identity.IsAuthenticated ? (int?)_userManager .FindByNameAsync(User.Identity.Name) .Result.TimeZoneOffset : null; context.News = _allNews.getObjectNews(Id); return(View(context)); }
public IActionResult EditComments(string text, string date, int newsId, int?id) { int[] d = date.Split(new char[] { '-' }).Select(el => int.Parse(el)).ToArray(); if (id == null) { Comment c = new Comment { Text = text, Author = User.Identity.Name, News = _allNews.getObjectNews(newsId), Date = new DateTime(d[0], d[1], d[2], d[3], d[4], d[5]).AddHours( -( _userManager .FindByNameAsync(User.Identity.Name) .Result.TimeZoneOffset ) ), }; _allComments.addComment(c); } return(RedirectToAction("GetItem", "NewsList", new { id = newsId })); }