public IActionResult Add(int id) { var viewmodel = new ClientClaimAddViewModel { ClientId = id, }; return(View(viewmodel)); }
public async Task <IActionResult> Add(ClientClaimAddViewModel viewmodel) { if (ModelState.IsValid) { var record = _mapper.Map <ClientClaim>(viewmodel); record.Id = 0; _dbContext.ClientClaims.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)); }