public async Task <IActionResult> Create(TalkEditViewModel model) { if (!string.IsNullOrEmpty(model?.DbModel?.Name)) { var talkId = await this._talks.Create(model.DbModel); return(RedirectToAction("Show", new { talkId })); } return(View("CreateOrEdit", new TalkEditViewModel { DbModel = new TalkDbModel(), AllSpeakers = await this._persons.GetAllPersons(), AllOrganizations = await this._organizations.GetAllOrganizations(), AllCategories = await this._cats.GetAllCategories() })); }
public async Task <IActionResult> Edit(int id, TalkEditViewModel model) { if (!string.IsNullOrEmpty(model?.DbModel?.Name)) { model.DbModel.Id = id; await this._talks.Update(model.DbModel); return(RedirectToAction("Show", new { id })); } return(View("CreateOrEdit", new TalkEditViewModel { DbModel = await this._talks.GetById(id), AllSpeakers = await this._persons.GetAllPersons(), AllOrganizations = await this._organizations.GetAllOrganizations(), AllCategories = await this._cats.GetAllCategories() })); }