public IActionResult Add(int id) { var viewmodel = new ClientIdpRestrictionAddViewModel { ClientId = id, }; return(View(viewmodel)); }
public async Task <IActionResult> Add(ClientIdpRestrictionAddViewModel viewmodel) { if (ModelState.IsValid) { var record = _mapper.Map <ClientIdPRestriction>(viewmodel); record.Id = 0; _dbContext.ClientIdPRestrictions.Add(record); var result = await _dbContext.SaveChangesAsync().ConfigureAwait(false); if (result > 0) { return(RedirectToAction("Details", "Clients", new { id = viewmodel.ClientId })); } ModelState.AddModelError("", "Failed"); } return(View(viewmodel)); }