public async Task <IActionResult> AddUserStory(UserStoryInputModel inputModel, int projectId) { if (!IsCurrentUserInProject(projectId)) { return(Unauthorized()); } if (!ModelState.IsValid) { inputModel.PrioritiesDropDown = this.mapper.Map <ICollection <BacklogPriorityDropDownModel> > (await this.backlogPrioritiesService.GetAllAsync()); return(View(inputModel)); } try { var savedFilepath = string.Empty; if (inputModel.Mockup?.Length > 0) { string filePath = Guid.NewGuid().ToString(); Account account = new Account( config["Cloudinary:CloudName"], config["Cloudinary:ApiKey"], config["Cloudinary:ApiSecret"] ); Cloudinary cloudinary = new Cloudinary(account); var uploadParams = new ImageUploadParams() { File = new FileDescription(filePath + ".png", inputModel.Mockup.OpenReadStream()), Overwrite = true, }; var uploadResult = cloudinary.Upload(uploadParams); savedFilepath = uploadResult.SecureUrl.AbsoluteUri; } inputModel.ProjectId = projectId; var inputDto = this.mapper.Map <UserStoryInputDto>(inputModel); inputDto.MockupPath = savedFilepath; await this.userStoryService.CreateAsync(inputDto); return(RedirectToAction(nameof(GetAll), new { projectId = projectId })); } catch (Exception) { return(RedirectToAction("Error", "Error")); } }
public async Task <IActionResult> AddUserStory(int projectId) { if (!IsCurrentUserInProject(projectId)) { return(Unauthorized()); } var createViewModel = new UserStoryInputModel() { PrioritiesDropDown = this.mapper.Map <ICollection <BacklogPriorityDropDownModel> > (await this.backlogPrioritiesService.GetAllAsync()), }; return(View(createViewModel)); }