public async Task <IActionResult> Edit(int id, DealerFormModel model) { var dealerExists = await this.dealerService.ExistsAsync(id); if (!dealerExists) { this.TempData.AddErrorMessage(WebAdminConstants.DealerNotFoundMsg); return(RedirectToAction(nameof(Index))); } if (!this.ModelState.IsValid) { return(this.View(model)); } await this.dealerService.UpdateAsync( id, model.Name, model.Description, model.BrandId); this.TempData.AddSuccessMessage(string.Format( WebAdminConstants.DealerUpdatedMsg, model.Name.ToStrongHtml())); return(this.RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(DealerFormModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } await this.dealerService.CreateAsync(model.Name, model.Description, model.BrandId); this.TempData.AddSuccessMessage(string.Format( WebAdminConstants.DealerCreatedMsg, model.Name.ToStrongHtml())); return(this.RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, DealerFormModel model) => await this.Handle( async() => await this.dealers .Edit(id, this.mapper.Map <DealerInputModel>(model)), success : RedirectToAction(nameof(Index)), failure : View(model));