public async Task <IActionResult> Post(ProjectPostInputViewModel inputModel) { if (!this.ModelState.IsValid) { var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; inputModel.AllCategories = allCategories; return(this.View(inputModel)); } var user = await this.userManager.GetUserAsync(this.User); var usersIds = this.usersService.GetUsersIdsFromEmailsString(inputModel.UsersEmails); var projectId = await this.projectsService.CreateAsync(inputModel.Title, inputModel.Description, user.Id); await this.categoryProjectsServices.CreateAsync(projectId, inputModel.CategoriesId); if (usersIds.Count != 0) { await this.projectOfferUsersServices.CreateAsync(projectId, usersIds); } this.TempData["SuccessPost"] = string.Format(PostSuccessMessage, inputModel.Title); return(this.RedirectToAction("Profile", "Users", new { id = user.Id })); }
public IActionResult Post() { var allCategories = new AllCategoriesViewModel { Categories = this.categoriesService.GetAll <CategoryListViewModel>(), }; var modelView = new ProjectPostInputViewModel { AllCategories = allCategories, }; return(this.View(modelView)); }