public ActionResult AddNewClient(int id) { var model = new AddNewClientViewModel { SearchProfileId = id }; return(View(model)); }
public ActionResult AddNewClient(AddNewClientViewModel model) { if (ModelState.IsValid) { if (_searchProfileService.AddClient(model)) { return(RedirectToAction("Detail", "SearchProfile", new { id = model.SearchProfileId })); } } return(View(model)); }
public bool AddClient(AddNewClientViewModel model) { var searchProfile = _applicationDbContext.SearchProfiles.Find(model.SearchProfileId); var client = _autoMapper.Map <Client>(model); if (searchProfile != null) { searchProfile.Clients.Add(client); _applicationDbContext.SaveChanges(); return(true); } return(false); }