public async Task <IActionResult> Edit(Post post, IFormFile imageFile) { var user = await _userManager.GetUserAsync(HttpContext.User); /* * if (post.Title.Length > 5) * { * ModelState.AddModelError("Title", "Недопустимая длина строки"); * } */ if (ModelState.IsValid) { post.UserId = user.Id; if (imageFile != null) { post.TitleImagePath = _imageService.Save(imageFile, this._webHostEnvironment, _configuration["ImagePath:Post"], post.UserId + "-" + post.PostedDate.ToString("dd-MM-yyyy-hh-mm-ss")); } post.PostedDate = _timeZoneService.GetUTCDateTime(post.PostedDate); _postService.Update(post); return(RedirectToAction(nameof(Index))); } ViewBag.Categories = new SelectList(_postCategoryService.GetAll(), "Id", "Name"); return(View(post)); }