public async Task <IActionResult> Create(MemberCreateInputModel input) { var groups = await this.groupsService.GetAll <GroupDropDownViewModel>().ToListAsync(); if (!this.ModelState.IsValid) { input.Groups = groups; return(this.View(input)); } try { var id = await this.membersService.CreateAsync(input.FullName, input.ImgUrl, input.Description, input.GroupId); this.TempData["Success"] = CreateSuccessMessage; return(this.Redirect("/Groups/Details/" + input.GroupId)); } catch (Exception e) { this.TempData["Error"] = e.Message; input.Groups = groups; return(this.View(input)); } }
public async Task <IActionResult> Create(int?id = null) { if (id != null) { this.TempData["groupId"] = id; return(this.View()); } var groups = await this.groupsService.GetAll <GroupDropDownViewModel>().ToListAsync(); var viewModel = new MemberCreateInputModel { Groups = groups, }; return(this.View(viewModel)); }