public virtual ActionResult ImportContact(int jsContactId, string jsCompanyId, string jsCompanyName, string name, string title, DateTime lastUpdated) { // Get all contacts and contacts for the user var contacts = _context.Contacts .Where(x => x.Company.JobSearch.User.Id == CurrentUserId) .Include(x => x.Company) .ToList(); var companies = _context.Companies .Where(x => x.JobSearch.User.Id == CurrentUserId) .ToList(); var model = new ImportContactViewModel { CompanyName = jsCompanyName, JigsawCompanyId = jsCompanyId, ContactName = name, ContactTitle = title, JigsawContactId = jsContactId, JigsawUpdatedDate = lastUpdated }; model.SetDropdownListValues(contacts, companies); return(View(model)); }
public virtual ActionResult ImportContact(ImportContactViewModel model) { if (!model.CreateNewContact && model.SelectedContactId <= 0) { ModelState.AddModelError("", "An existing contact must be selected to merge, or you must mark this as a new contact"); } else if (model.CreateNewContact && !model.CreateNewCompany && model.SelectedCompanyId <= 0) { ModelState.AddModelError("", "An existing company must be selected to add the contact to an existing company"); } if (!ModelState.IsValid) { // Get all contacts for the user var contacts = _context.Contacts .Where(x => x.Company.JobSearch.User.Id == CurrentUserId) .Include(x => x.Company) .OrderBy(x => x.Name) .ToList(); model.SetDropdownListValues(contacts, contacts.Select(x => x.Company).Distinct().ToList()); return(View(model)); } // Pass to the merge screen if we are not creating a new contact if (!model.CreateNewContact) { return(RedirectToAction(MVC.ContactSearch.Sync.Jigsaw(model.SelectedContactId, model.JigsawContactId, model.ContactName, model.ContactTitle, model.JigsawUpdatedDate))); } // Otherwise create the new contact var parameters = Mapper.Map <ImportContactViewModel, AddJigsawContactToJobSearchParams>(model); parameters.RequestingUserId = CurrentUserId; var result = _addContactProc.Execute(parameters); return(RedirectToAction(MVC.ContactSearch.Jigsaw.AddContactSuccessful(result.ContactId, result.ContactName, result.CompanyName, result.CompanyId))); }
public virtual ActionResult ImportContact(int jsContactId, string jsCompanyId, string jsCompanyName, string name, string title, DateTime lastUpdated) { // Get all contacts and contacts for the user var contacts = _context.Contacts .Where(x => x.Company.JobSearch.User.Id == CurrentUserId) .Include(x => x.Company) .ToList(); var companies = _context.Companies .Where(x => x.JobSearch.User.Id == CurrentUserId) .ToList(); var model = new ImportContactViewModel { CompanyName = jsCompanyName, JigsawCompanyId = jsCompanyId, ContactName = name, ContactTitle = title, JigsawContactId = jsContactId, JigsawUpdatedDate = lastUpdated }; model.SetDropdownListValues(contacts, companies); return View(model); }
public virtual ActionResult ImportContact(ImportContactViewModel model) { if (!model.CreateNewContact && model.SelectedContactId <= 0) ModelState.AddModelError("", "An existing contact must be selected to merge, or you must mark this as a new contact"); else if (model.CreateNewContact && !model.CreateNewCompany && model.SelectedCompanyId <= 0) ModelState.AddModelError("", "An existing company must be selected to add the contact to an existing company"); if (!ModelState.IsValid) { // Get all contacts for the user var contacts = _context.Contacts .Where(x => x.Company.JobSearch.User.Id == CurrentUserId) .Include(x => x.Company) .OrderBy(x => x.Name) .ToList(); model.SetDropdownListValues(contacts, contacts.Select(x => x.Company).Distinct().ToList()); return View(model); } // Pass to the merge screen if we are not creating a new contact if (!model.CreateNewContact) return RedirectToAction(MVC.ContactSearch.Sync.Jigsaw(model.SelectedContactId, model.JigsawContactId, model.ContactName, model.ContactTitle, model.JigsawUpdatedDate)); // Otherwise create the new contact var parameters = Mapper.Map<ImportContactViewModel, AddJigsawContactToJobSearchParams>(model); parameters.RequestingUserId = CurrentUserId; var result = _addContactProc.Execute(parameters); return RedirectToAction(MVC.ContactSearch.Jigsaw.AddContactSuccessful(result.ContactId, result.ContactName, result.CompanyName, result.CompanyId)); }