public async Task CreateAsync(CreateNoteInputModel input, string userId) { var note = new Note { Title = input.Title, Description = input.Description, CreatedByUserId = userId, }; await this.notesRepository.AddAsync(note); await this.notesRepository.SaveChangesAsync(); }
public async Task <IActionResult> Create(CreateNoteInputModel input) { if (!this.ModelState.IsValid) { return(this.View(input)); } var user = await this.userManager.GetUserAsync(this.User); await this.notesService.CreateAsync(input, user.Id); try { await this.notesService.CreateAsync(input, user.Id); } catch (Exception ex) { this.ModelState.AddModelError(string.Empty, ex.Message); return(this.View(input)); } return(this.Redirect("/notes/all")); }
public IActionResult Create() { var viewModel = new CreateNoteInputModel(); return(this.View(viewModel)); }