public async Task <IActionResult> AddForum(AddForumModel model) { var imageUrl = ""; if (model.ImageUrl == null) { var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUrl }; await _forumService.Create(forum); } else { var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = model.ImageUrl }; await _forumService.Create(forum); } return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/users/default.png"; if (model.ImageUpload != null && model.ImageUpload.Length != 0) { //var blockBlob = UploadForumImage(model.ImageUpload); //imageUri = blockBlob.Uri.AbsoluteUri; string pathRoot = _environment.WebRootPath; string path_to_Images = pathRoot + "\\Images\\forum\\" + model.ImageUpload.FileName; using (var stream = new FileStream(path_to_Images, FileMode.Create)) { await model.ImageUpload.CopyToAsync(stream); } imageUri = "/Images/forum/" + model.ImageUpload.FileName; } var forum = new Forum { Title = model.Title, Descripition = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = ""; if (model.ImageUpload != null) { var blockBlob = UploadForumImage(model.ImageUpload); imageUri = blockBlob.Uri.AbsoluteUri; } else { imageUri = "/images/users/default.png"; } var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var forum = new Forum { Title = model.Title, Description = model.Description, CreatedTime = DateTime.Now }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <ActionResult> AddForum(AddNewForumModel model) { var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now }; await _forumRepositories.Create(forum); return(RedirectToAction("Index")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/users/default.png"; var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public IActionResult CreateForum(ForumViewModel forum) { var user = _userManager.FindByNameAsync(User.Identity.Name).Result; var model = new Forum { ImageUrl = forum.ImageUrl, Description = forum.Description, Created = DateTime.Now, Title = forum.Name, User = user, }; _forumService.Create(model); _userService.IncementRating(user.Id, typeof(Forum)); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddNewForum(NewForumModel model) { var ImageUri = "default.png"; if (model.ImageUpload != null) { ImageUri = GetImageUri(model.ImageUpload); } var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = "/images/" + ImageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> Create(ForumNewModel model) { if (ModelState.IsValid) { string urlImage = ""; string roorPath = _hostingEnviroment.WebRootPath; model.ImageForum = HttpContext.Request.Form.Files; var idNew = Guid.NewGuid(); var supportedTypes = new[] { ".jpg", ".jpeg", ".png" }; if (model.ImageForum.Count != 0) { var uploads = Path.Combine(roorPath, SD.FolderDefault + "/" + SD.FolderImages + "/" + SD.pathForum); var extension = Path.GetExtension(model.ImageForum[0].FileName).ToLower(); using (var filestream = new FileStream(Path.Combine(uploads, idNew + extension), FileMode.Create)) { model.ImageForum[0].CopyTo(filestream); } if (!supportedTypes.Contains(extension)) { TempData["Message"] = "file fail!"; return(RedirectToAction(nameof(Create))); } else { urlImage = idNew + extension; } } var forum = new Forum { Title = model.Title, Description = model.Description, ImageUrl = urlImage }; await _forumService.Create(forum); return(RedirectToAction(nameof(Index))); } return(View(nameof(Create))); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/forum/forum.png"; //if (model.ImageUpload != null) //{ // var blocBlob = UploadForumImage(model.ImageUpload); // imageUri = blocBlob.Uri.AbsoluteUri; //} var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forum.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/forum/forum.png"; if (model.file != null) { imageUri = await UploadForumImage(model.file); } var forum = new Forum() { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/ico/bibliomit.svg"; if (model?.ImageUpload != null) { imageUri = UploadForumImage(model.ImageUpload); } var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = new Uri(imageUri) }; await _forumService.Create(forum).ConfigureAwait(false); return(RedirectToAction("Index", "Fora")); }
public async Task <IActionResult> AddForum(AddForumModel model) { var imageUri = "/images/forum/default.png"; if (model.ImageUpload != null) { string uploadImage = SaveUploadImage(model.ImageUpload); imageUri = uploadImage; } var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = imageUri }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumViewModel model) { string imageUrl = "/images/users/default.png"; if (model.ImageUpload != null) { imageUrl = UploadForumImage(model.ImageUpload); imageUrl = "/images/" + Path.GetFileName(model.ImageUpload.FileName); } var forum = new Forum() { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageURL = imageUrl }; await forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }
public async Task <IActionResult> AddForum(AddForumModel model, IFormCollection image1) { string storePath = "/images/forum/"; var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", "images", "forum", image1.Files[0].FileName); using (var stream = new FileStream(path, FileMode.Create)) { await image1.Files[0].CopyToAsync(stream); } var forum = new Forum { Title = model.Title, Description = model.Description, Created = DateTime.Now, ImageUrl = storePath + model.ImageUpload.FileName }; await _forumService.Create(forum); return(RedirectToAction("Index", "Forum")); }