public async Task <ActionResult> New([Bind("ContactName,MatterNo,Location,PracticeArea,Firm,PQE,CreatedOn,Source,SourceOther")] ContactViewModel form, string returnUrl = null) { // var AzureUser.CurrentUser = _httpContextAccessor.HttpContext.User.Identity.Name.Split('\\')[1]; form.CreatedBy = AzureUser.CurrentUser; //TODO: set to cached current user if (ModelState.IsValid) { int exists = await _appsService.CheckIfContactExists(form.ContactName, form.Firm); if (exists > 0) { _toastNotification.AddErrorToastMessage("Contact Already Exists", new ToastrOptions() { ProgressBar = false }); await LoadLists(); ViewBag.FirmsList = _firmsList; ViewBag.SourceList = _sourcesLst; ViewBag.LocationList = _locationsLst; ViewBag.PracticeAreaList = _practiceAreaLst; ViewBag.PQEsList = _pqeLst; return(View(form)); } //MAPPER NEEDED ContactDto entry = new ContactDto { ContactName = form.ContactName , MatterNo = form.MatterNo , Location = form.Location , PQE = form.PQE , PracticeArea = form.PracticeArea , Firm = form.Firm , CreatedOn = form.CreatedOn , CreatedBy = form.CreatedBy , Source = form.Source , SourceOther = form.SourceOther }; // int result = await _appsService.CreateContact(entry); if (result >= 1) { //trying to return to were we came from (Could use category to determine this also) _toastNotification.AddInfoToastMessage("New Contact Added", new ToastrOptions() { ProgressBar = false }); return(RedirectToAction("Index")); } else { _toastNotification.AddErrorToastMessage("Error, Contact Not Added", new ToastrOptions() { ProgressBar = false }); } } else { await LoadLists(); ViewBag.FirmsList = _firmsList; ViewBag.SourceList = _sourcesLst; ViewBag.LocationList = _locationsLst; ViewBag.PracticeAreaList = _practiceAreaLst; ViewBag.PQEsList = _pqeLst; return(View(form)); } await LoadLists(); ViewBag.FirmsList = _firmsList; ViewBag.SourceList = _sourcesLst; ViewBag.LocationList = _locationsLst; ViewBag.PracticeAreaList = _practiceAreaLst; ViewBag.PQEsList = _pqeLst; return(View(form)); }