public ActionResult _AddLeadScore() { LeadScoreRuleViewModel viewModel = new LeadScoreRuleViewModel(); viewModel.AccountID = this.Identity.ToAccountID(); var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); viewModel.TourTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.TourType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); viewModel.LeadsourceTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LeadSources).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); viewModel.NoteCategories = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.NoteCategory).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); viewModel.ActionTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.ActionType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); GetLeadScoreCategoriesResponse categoriesResponse = leadScoreService.GetLeadScoreCategories(new GetLeadScoreCategoriesRequest() { }); viewModel.Categories = categoriesResponse.Categories; GetLeadScoreConditionsResponse conditionsResponce = leadScoreService.GetLeadScoreConditions(new GetLeadScoreConditionsRequest() { }); viewModel.Conditions = conditionsResponce.Conditions; var leadScoreConditionValues = new List <LeadScoreConditionValueViewModel>(); var newConditionValue = new LeadScoreConditionValueViewModel() { LeadScoreConditionValueId = 0, LeadScoreRuleId = 0, Value = "", ValueType = LeadScoreValueType.PageDuration }; leadScoreConditionValues.Add(newConditionValue); viewModel.LeadScoreConditionValues = leadScoreConditionValues; return(PartialView("_AddEditRule", viewModel)); }
public HttpResponseMessage GetDropdownValues(DropdownFieldTypes DropDownID) { var dropdownValues = cachingService.GetDropdownValues(this.AccountId); var liefcyclestages = dropdownValues.Where(k => k.DropdownID == (byte)DropDownID) .Select(k => k.DropdownValuesList) .ToList().FirstOrDefault() .Where(d => d.IsActive == true); return(Request.CreateResponse(HttpStatusCode.OK, liefcyclestages)); }
public ActionResult AddLeadAdapter() { LeadAdapterViewModel viewModel = new LeadAdapterViewModel(); var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); viewModel.LeadSourceDropdownValues = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LeadSources) .Select(s => s.DropdownValuesList).FirstOrDefault() .Where(d => d.IsActive == true); ViewBag.FacebookAPPId = leadAdapterService.GetFacebookApp(new GetFacebookAppRequest() { AccountId = this.Identity.ToAccountID() }).FacebookAppID; return(View("AddEditLeadAdapter", viewModel)); }
public override void Process() { leadAdapterAndAccountMap = leadAdaptersRepository.GetLeadAdapterByID(LeadAdapterAccountMapID); ServiceProvider ServiceProviders = serviceProviderRepository .GetServiceProviders(1, CommunicationType.Mail, MailType.TransactionalEmail); var response = customFieldService.GetAllCustomFields(new GetAllCustomFieldsRequest(leadAdapterAndAccountMap.AccountID)); IEnumerable <FieldViewModel> customFields = response.CustomFields; var dropdownfeildsresposne = cacheService.GetDropdownValues(leadAdapterAndAccountMap.AccountID); IEnumerable <DropdownValueViewModel> phoneFields = dropdownfeildsresposne.Where(x => x.DropdownID == (short)DropdownFieldTypes.PhoneNumberType).Select(x => x.DropdownValuesList).FirstOrDefault(); var jobLogId = InsertJobLog(leadAdapterAndAccountMap); var contacts = this.GetContacts("lead_feed.xml", customFields, jobLogId, phoneFields); if (contacts.ContactData != null && contacts.ContactData.Any()) { Logger.Current.Informational("Got contacts for inserting : " + contacts.ContactData.Count); /* Bulk Insert */ Task.Factory.StartNew(() => { MailgunVerification(contacts.ContactData.ToList()); }, TaskCreationOptions.LongRunning); Task.Factory.StartNew(() => { ContactsBulkinsert(contacts); }, TaskCreationOptions.LongRunning); } else { Logger.Current.Informational("No contacts for inserting, Account name : " + leadAdapterAndAccountMap.AccountName); } }
public JsonResult GetHotListContacts() { var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); ReportViewModel viewModel = new ReportViewModel { CustomStartDate = DateTime.Now.ToUniversalTime().AddDays(-30), CustomEndDate = DateTime.Now.ToUniversalTime(), PageNumber = 1, ShowTop = 10 }; var lifecycleStages = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LifeCycle) .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true).Select(d => d.DropdownValueID).ToArray(); viewModel.LifeStageIds = lifecycleStages; ReportDataResponse response = reportService.GetHotListData(new ReportDataRequest { ReportViewModel = viewModel, AccountId = this.Identity.ToAccountID(), UserId = this.Identity.ToUserID(), RoleId = this.Identity.ToRoleID(), IsSTAdmin = this.Identity.IsSTAdmin(), IsDasboardView = true }); response.ReportId = GetReportId(Reports.HotList); response.HotlistGridData.Contacts = response.ContactIds = new List <int>(); return(Json(new { success = true, response = response }, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage GetHotListLeads() { var dropdownValues = cachingService.GetDropdownValues(this.AccountId); ReportViewModel viewModel = new ReportViewModel { CustomStartDate = DateTime.Now.ToUniversalTime().AddDays(-30), CustomEndDate = DateTime.Now.ToUniversalTime(), PageNumber = 1, ShowTop = 10 }; var lifecycleStages = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LifeCycle) .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true).Select(d => d.DropdownValueID).ToArray(); viewModel.LifeStageIds = lifecycleStages; ReportDataResponse response = reportService.GetHotListData(new ReportDataRequest { ReportViewModel = viewModel, AccountId = this.AccountId, UserId = this.UserId, RoleId = this.RoleId, IsSTAdmin = this.IsSTAdmin, IsDasboardView = true }); response.ReportId = GetReportId(Reports.HotList); response.HotlistGridData.Contacts = response.ContactIds = new List <int>(); return(Request.BuildResponse(response)); }
public ActionResult Actions() { short ItemsPerPage = default(short); short.TryParse(this.Identity.ToItemsPerPage(), out ItemsPerPage); ViewBag.ItemsPerPage = ItemsPerPage; ViewBag.IsMyActions = true; ViewBag.DateFormat = this.Identity.ToDateFormat(); ViewBag.UserIds = new List <int>(); var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); var actionTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.ActionType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); List <SelectListItem> selectedListItems = new List <SelectListItem>(); SelectListItem selectListItem1 = new SelectListItem(); selectListItem1.Text = "Select"; selectListItem1.Value = "0"; selectedListItems.Add(selectListItem1); foreach (DropdownValueViewModel item in actionTypes) { SelectListItem selectListItem = new SelectListItem(); selectListItem.Text = item.DropdownValue; selectListItem.Value = item.DropdownValueID.ToString(); selectedListItems.Add(selectListItem); } ViewBag.ActionTypes = selectedListItems; return(View("~/Views/Contact/ActionList.cshtml")); }
private IEnumerable <DropdownValueViewModel> GetPhoneDropdownFields() { var dropdownfeildsresposne = cacheService.GetDropdownValues(leadAdapterAndAccountMap.AccountID); IEnumerable <DropdownValueViewModel> phoneFields = dropdownfeildsresposne.Where(x => x.DropdownID == (short)DropdownFieldTypes.PhoneNumberType).Select(x => x.DropdownValuesList).FirstOrDefault(); return(phoneFields); }
public JsonResult GetAccountDropdownValues() { var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); return(Json(new { success = true, response = dropdownValues }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetDropdownValues(DropdownFieldTypes DropDownID) { var dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); var lifecyclestages = dropdownValues.Where(k => k.DropdownID == (byte)DropDownID).Select(k => k.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); return(Json(new { success = true, response = lifecyclestages }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetLeadSources() { IEnumerable <DropdownViewModel> dropdownValues = cachingService.GetDropdownValues(this.Identity.ToAccountID()); var values = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LeadSources).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true && d.IsDeleted == false); return(Json(new { success = true, response = values }, JsonRequestBehavior.AllowGet)); }
public GetRelationshipResponse GetContactRelationship(int contactRelationMapID, int accountID) { GetRelationshipResponse response = new GetRelationshipResponse(); RelationshipViewModel viewModel = new RelationshipViewModel(); var dropdowns = cachingService.GetDropdownValues(accountID); ContactRelationship relationship = contactRelationshipRepository.FindBy(contactRelationMapID); IList <ContactRelationship> relationshipList = new List <ContactRelationship>(); relationshipList.Add(relationship); viewModel.Relationshipentry = Mapper.Map <IEnumerable <ContactRelationship>, IEnumerable <RelationshipEntry> >(relationshipList).ToList(); viewModel.RelationshipTypes = dropdowns.Where(s => s.DropdownID == (short)DropdownFieldTypes.RelationshipType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive); response.RelationshipViewModel = viewModel; return(response); }
private PersonViewModel GetUpdatedPersonData(PersonViewModel existingModel, PersonViewModel newModel) { Person person = new Person(); var dropdownValues = _cachingService.GetDropdownValues(newModel.AccountID); existingModel.FirstName = !string.IsNullOrEmpty(newModel.FirstName) ? newModel.FirstName : existingModel.FirstName; existingModel.LastName = !string.IsNullOrEmpty(newModel.LastName) ? newModel.LastName : existingModel.LastName; existingModel.CompanyName = !string.IsNullOrEmpty(newModel.CompanyName) ? newModel.CompanyName : existingModel.CompanyName; existingModel.Title = !string.IsNullOrEmpty(newModel.Title) ? newModel.Title : existingModel.Title; List <short> phoneTypeIds = newModel.Phones.IsAny() ? newModel.Phones.Select(p => p.PhoneType).ToList() : new List <short>(); List <short> dropdownValueTyeIds = new List <short>(); if (phoneTypeIds.IsAny()) { dropdownValueTyeIds = _formRepository.GetDropdownValueTypeIdsByPhoneTypes(phoneTypeIds, newModel.AccountID); } var mobilePhoneNumber = dropdownValueTyeIds.Contains((short)DropdownValueTypes.MobilePhone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null; var homePhoneNumber = dropdownValueTyeIds.Contains((short)DropdownValueTypes.Homephone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null; var workPhoneNumber = dropdownValueTyeIds.Contains((short)DropdownValueTypes.WorkPhone) ? newModel.Phones.Select(m => m.Number).FirstOrDefault() : null; var phoneTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.PhoneNumberType) .Select(s => s.DropdownValuesList).FirstOrDefault().Where(d => d.IsActive == true); existingModel.Phones = new List <Phone>(); Log.Informational("While Updating phones."); IEnumerable <Phone> existingPhones = _formRepository.GetPhoneFields(existingModel.ContactID); Phone mobilePhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).FirstOrDefault(); if (!string.IsNullOrEmpty(mobilePhoneNumber) && !(mobilePhoneNumber.Length < 10 || mobilePhoneNumber.Length > 15)) { string number = mobilePhoneNumber.TrimStart(new char[] { '0', '1' }); Phone phone = new Phone(); phone.Number = number; phone.AccountID = existingModel.AccountID; phone.IsPrimary = mobilePhone != null ? mobilePhone.IsPrimary : (homePhoneNumber == null && workPhoneNumber == null && !existingPhones.IsAny()) || phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.IsDefault).FirstOrDefault(); phone.PhoneType = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.DropdownValueID).FirstOrDefault(); phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.MobilePhone).Select(c => c.DropdownValue).FirstOrDefault(); if (person.IsValidPhoneNumberLength(number)) { existingModel.Phones.Add(phone); } } else if (mobilePhone != null) { existingModel.Phones.Add(mobilePhone); } Phone homePhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).FirstOrDefault(); if (!string.IsNullOrEmpty(homePhoneNumber) && !(homePhoneNumber.Length < 10 || homePhoneNumber.Length > 15)) { string number = homePhoneNumber.TrimStart(new char[] { '0', '1' }); Phone phone = new Phone(); phone.Number = number; phone.AccountID = existingModel.AccountID; phone.IsPrimary = homePhone != null ? homePhone.IsPrimary : (mobilePhoneNumber == null && workPhoneNumber == null && !existingPhones.IsAny()) || phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.IsDefault).FirstOrDefault(); phone.PhoneType = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.DropdownValueID).FirstOrDefault(); phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.Homephone).Select(c => c.DropdownValue).FirstOrDefault(); if (person.IsValidPhoneNumberLength(number)) { existingModel.Phones.Add(phone); } } else if (homePhone != null) { existingModel.Phones.Add(homePhone); } Phone workPhone = existingPhones.Where(w => w.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).FirstOrDefault(); if (!string.IsNullOrEmpty(workPhoneNumber) && !(workPhoneNumber.Length < 10 || workPhoneNumber.Length > 15)) { string number = workPhoneNumber.TrimStart(new char[] { '0', '1' }); Phone phone = new Phone(); phone.Number = number; phone.AccountID = existingModel.AccountID; phone.IsPrimary = workPhone != null ? workPhone.IsPrimary : (mobilePhoneNumber == null && homePhoneNumber == null && !existingPhones.IsAny()) || phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.IsDefault).FirstOrDefault(); phone.PhoneType = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.DropdownValueID).FirstOrDefault(); phone.PhoneTypeName = phoneTypes.Where(c => c.DropdownValueTypeID == (short)DropdownValueTypes.WorkPhone).Select(c => c.DropdownValue).FirstOrDefault(); if (person.IsValidPhoneNumberLength(number)) { existingModel.Phones.Add(phone); } } else if (workPhone != null) { existingModel.Phones.Add(workPhone); } IEnumerable <Phone> existingNonDefaultPhones = existingPhones.Where(w => w.DropdownValueTypeID != 9 && w.DropdownValueTypeID != 10 && w.DropdownValueTypeID != 11 && !w.IsDeleted); if (existingNonDefaultPhones.IsAny()) { existingNonDefaultPhones.Each(e => { if (phoneTypeIds.IsAny()) { if (phoneTypeIds.Contains(e.PhoneType)) { var nonDefaultPhone = newModel.Phones.Where(p => p.PhoneType == e.PhoneType).FirstOrDefault();//workPhoneNumber.TrimStart(new char[] { '0', '1' }); string number = nonDefaultPhone.Number.TrimStart(new char[] { '0', '1' }); if (e.Number != number) { e.IsPrimary = false; Phone phone = new Phone(); phone.Number = number; phone.AccountID = existingModel.AccountID; phone.IsPrimary = true; phone.PhoneType = nonDefaultPhone.PhoneType; phone.PhoneTypeName = nonDefaultPhone.PhoneTypeName; if (person.IsValidPhoneNumberLength(number.TrimStart(new char[] { '0', '1' }))) { existingModel.Phones.Add(phone); } } } } existingModel.Phones.Add(e); }); } Log.Informational("While Updating Addresses."); existingModel.Addresses = new List <AddressViewModel>(); var addressLine1 = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.AddressLine1).FirstOrDefault() : null; var addressLine2 = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.AddressLine2).FirstOrDefault() : null; var city = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.City).FirstOrDefault() : null; var state = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.State).FirstOrDefault() : null; var zip = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.ZipCode).FirstOrDefault() : null; var country = newModel.Addresses.IsAny() ? newModel.Addresses.Select(a => a.Country).FirstOrDefault() : null; if (addressLine1 != null || addressLine2 != null || city != null || zip != null || country != null || state != null) { existingModel.AddressTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.AddressType) .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); AddressViewModel newAddress = new AddressViewModel(); newAddress.AddressTypeID = existingModel.AddressTypes.SingleOrDefault(a => a.IsDefault).DropdownValueID; newAddress.AddressLine1 = addressLine1 != null && !string.IsNullOrEmpty(addressLine1) ? addressLine1 : ""; newAddress.AddressLine2 = addressLine2 != null && !string.IsNullOrEmpty(addressLine2) ? addressLine2 : ""; newAddress.City = city != null && !string.IsNullOrEmpty(city) ? city : ""; if (state != null) { newAddress.State = new State() { Code = state.Code } } ; else { newAddress.State = new State(); } if (country != null) { newAddress.Country = new Country() { Code = country.Code } } ; else { newAddress.Country = new Country(); } var zipCode = zip != null && !string.IsNullOrEmpty(zip) ? zip : ""; newAddress.ZipCode = zipCode; newAddress.IsDefault = true; if ((newAddress.State != null && !string.IsNullOrEmpty(newAddress.State.Code)) && (newAddress.Country == null || string.IsNullOrEmpty(newAddress.Country.Code))) { newAddress.Country = new Country(); newAddress.Country.Code = newAddress.State.Code.Substring(0, 2); } existingModel.Addresses.Add(newAddress); } existingModel.ContactType = Entities.ContactType.Person.ToString(); existingModel.SecondaryEmails = new List <dynamic>(); Log.Informational("While Updating Life Cycle Stage."); existingModel.LifecycleStages = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.LifeCycle) .Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); var defaultLifeCycleType = existingModel.LifecycleStages.SingleOrDefault(a => a.IsDefault); if (newModel.LifecycleStage > 0) { if (!existingModel.LifecycleStages.Where(l => l.DropdownValueID == newModel.LifecycleStage).IsAny()) { newModel.LifecycleStage = existingModel.LifecycleStages.Where(l => l.IsDefault).Select(s => s.DropdownValueID).FirstOrDefault(); } } existingModel.LifecycleStage = newModel.LifecycleStage > 0 ? newModel.LifecycleStage : defaultLifeCycleType.DropdownValueID; existingModel.AccountID = newModel.AccountID; existingModel.LastUpdatedOn = DateTime.Now.ToUniversalTime(); GetAllCustomFieldsResponse accountCustomFields = new GetAllCustomFieldsResponse(); GetAllCustomFieldsRequest request = new GetAllCustomFieldsRequest(newModel.AccountID); accountCustomFields.CustomFields = _customFieldService.GetAllCustomFields(request).CustomFields; if (newModel.CustomFields.IsAny()) { Log.Informational("While Updating Custom fields."); foreach (ContactCustomFieldMapViewModel submittedField in newModel.CustomFields) { try { var isCustomField = accountCustomFields.CustomFields.Where(c => c.FieldId == submittedField.CustomFieldId).FirstOrDefault(); if (isCustomField != null) { ContactCustomFieldMapViewModel contactCustomField = new ContactCustomFieldMapViewModel(); contactCustomField.CustomFieldId = submittedField.CustomFieldId; contactCustomField.Value = submittedField.Value; contactCustomField.FieldInputTypeId = (int)isCustomField.FieldInputTypeId; contactCustomField.ContactId = existingModel.ContactID; var existingCustomField = existingModel.CustomFields.Where(c => c.CustomFieldId == isCustomField.FieldId).FirstOrDefault(); if (existingCustomField == null) { existingModel.CustomFields.Add(contactCustomField); } else { existingCustomField.Value = submittedField.Value; } } } catch { Log.Informational("While Update: Submitted customfieldId: " + submittedField.CustomFieldId + " cannot be Updated. Value: " + submittedField.Value); } } } return(existingModel); }
public HttpResponseMessage MyProfile() { int userId = this.UserId; int accountId = this.IsSTAdmin ? 1 : this.AccountId; GetUserResponse response = userService.GetUser(new GetUserRequest(userId)); MyProfileViewModel model = new MyProfileViewModel(); GetUserSettingResponse userSettingResp = new GetUserSettingResponse(); UserSettingsViewModel settings = new UserSettingsViewModel(); settings.AccountId = accountId; var dropdownValues = cachingService.GetDropdownValues(null); var defaultAddressFields = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.AddressType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault(); var defaultPhoneFields = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.PhoneNumberType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault(); var defaultAddressType = defaultAddressFields.Where(d => d.IsDefault == true).FirstOrDefault(); var defaultPhoneType = defaultPhoneFields.Where(d => d.IsDefault == true).FirstOrDefault(); IList <Email> EmailList = new List <Email>(); settings.DateFormat = 2; settings.ItemsPerPage = 25; settings.TimeZone = this.TimeZone; settings.CountryId = "CA"; settings.CurrencyID = 1; settings.UserId = userId; settings.EmailSignature = ""; settings.Emails = EmailList; if (response.User != null) { Logger.Current.Verbose("User found"); response.User.AddressTypes = defaultAddressFields.Where(d => d.IsActive == true); response.User.PhoneNumberTypes = defaultPhoneFields.Where(d => d.IsActive == true); if (response.User.Phones.Count == 0) { Logger.Current.Verbose("No phones found for this user"); response.User.Phones = new List <Phone>() { new Phone() { Number = "", PhoneType = defaultPhoneType.DropdownValueTypeID, IsPrimary = true, ContactPhoneNumberID = 0 } }; } if (response.User.Addresses.Count == 0) { Logger.Current.Verbose("No address found for this user"); Address accAddress = userService.GetAccountAddress(new GetAccountAddressRequest() { AccountId = accountId }).Address; if (accAddress != null) { response.User.Addresses = new List <AddressViewModel>() { new AddressViewModel() { AddressID = 0, AddressTypeID = defaultAddressType.DropdownValueID, State = new State { Code = accAddress.State.Code, Name = accAddress.State.Name }, Country = new Country { Code = accAddress.Country.Code, Name = accAddress.Country.Name }, IsDefault = true } }; } } userSettingResp = userService.GetUserSetting(new GetUserSettingRequest() { AccountID = accountId, UserID = userId }); if (userSettingResp.UserSettingsViewModel != null) { userSettingResp.UserSettingsViewModel.Emails = response.User.Emails; } else { settings.Emails = response.User.Emails; } model.userViewModel = response.User; model.userSettingsViewModel = userSettingResp.UserSettingsViewModel == null ? settings : userSettingResp.UserSettingsViewModel; Logger.Current.Verbose("viewmodel is initialized"); } else { Logger.Current.Verbose("user not found"); model.userSettingsViewModel = settings; var userViewModel = new UserViewModel(); userViewModel.Phones = new List <Phone>() { new Phone() { Number = "", PhoneType = defaultPhoneType.DropdownValueTypeID, IsPrimary = true, ContactPhoneNumberID = 0 } }; userViewModel.Addresses = new List <AddressViewModel>() { new AddressViewModel() { AddressID = 0, AddressTypeID = defaultAddressType.DropdownValueID, Country = new Country { Code = "" }, State = new State { Code = "" }, IsDefault = true } }; model.userViewModel = userViewModel; } Logger.Current.Verbose("Loading my-profile page"); return(Request.CreateResponse(model)); }
public ActionResult AddEditUser(int userId) { GetUserResponse response = userService.GetUser(new GetUserRequest(userId)); var dropdownValues = cachingService.GetDropdownValues(null); response.User.AddressTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.AddressType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); response.User.PhoneNumberTypes = dropdownValues.Where(s => s.DropdownID == (byte)DropdownFieldTypes.PhoneNumberType).Select(s => s.DropdownValuesList).ToList().FirstOrDefault().Where(d => d.IsActive == true); var defaultAddressType = response.User.AddressTypes.SingleOrDefault(a => a.IsDefault == true); Address accAddress = userService.GetAccountAddress(new GetAccountAddressRequest() { AccountId = this.Identity.ToAccountID() }).Address; if (response.User.Addresses.Count == 0) { if (accAddress != null) { response.User.Addresses = new List <AddressViewModel>() { new AddressViewModel() { AddressID = 0, AddressTypeID = defaultAddressType.DropdownValueID, State = new State { Code = accAddress.State.Code, Name = accAddress.State.Name }, Country = new Country { Code = accAddress.Country.Code, Name = accAddress.Country.Name }, IsDefault = true } }; } } ViewBag.PageName = "EditUser"; ViewBag.NewAddress = new AddressViewModel() { AddressID = 0, AddressTypeID = defaultAddressType.DropdownValueID, Country = new Country { Code = accAddress.Country.Code, Name = accAddress.Country.Name }, State = new State { Code = accAddress.State.Code, Name = accAddress.State.Name }, IsDefault = true }; var defaultPhoneType = response.User.PhoneNumberTypes.SingleOrDefault(a => a.IsDefault == true); if (response.User.Phones.Count == 0) { response.User.Phones = new List <Phone>() { new Phone() { Number = "", PhoneType = defaultPhoneType.DropdownValueTypeID, IsPrimary = true, ContactPhoneNumberID = 0 } }; } return(View("AddEditUser", response.User)); }
private void readLocalFiles(FtpService ftpManager) { DirectoryInfo d = new DirectoryInfo(leadAdapterAndAccountMap.LocalFilePath); FileInfo[] Files = d.GetFiles("*.xml"); if (Files != null && Files.Count() > 0) { var response = customFieldService.GetAllCustomFields(new GetAllCustomFieldsRequest(leadAdapterAndAccountMap.AccountID)); IEnumerable <FieldViewModel> customFields = response.CustomFields; var dropdownfeildsresposne = cacheService.GetDropdownValues(leadAdapterAndAccountMap.AccountID); IEnumerable <DropdownValueViewModel> phoneFields = dropdownfeildsresposne.Where(x => x.DropdownID == (short)DropdownFieldTypes.PhoneNumberType).Select(x => x.DropdownValuesList).FirstOrDefault(); Logger.Current.Informational("Processing files for account : " + leadAdapterAndAccountMap.AccountName + " count of files : " + Files.LongLength); foreach (var file in Files) { Logger.Current.Informational("Current Processed File Name: " + file.Name); var localFilePath = Path.Combine(leadAdapterAndAccountMap.LocalFilePath, file.Name); try { int jobid = Convert.ToInt32(Path.GetFileNameWithoutExtension(localFilePath).Split('~')[1]); var fileName = Path.GetFileNameWithoutExtension(localFilePath).Split('~')[0] + Path.GetExtension(localFilePath); /* Get contacts */ var contacts = new ImportContactsData(); contacts = GetContacts(localFilePath, customFields, jobid, phoneFields); if (contacts.ContactData != null && contacts.ContactData.Any()) { Logger.Current.Informational("Got contacts for inserting : " + contacts.ContactData.Count); /* Bulk Insert */ Task.Factory.StartNew(() => { MailgunVerification(contacts.ContactData.ToList()); }, TaskCreationOptions.LongRunning); Task.Factory.StartNew(() => { ContactsBulkinsert(contacts); }, TaskCreationOptions.LongRunning); } else { Logger.Current.Informational("No contacts for inserting, Account name : " + leadAdapterAndAccountMap.AccountName); } /* File move to archive after processing */ var fileExtension = Path.GetExtension(localFilePath); var newFileName = Guid.NewGuid() + fileExtension; importDataRepository.UpdateLeadAdapterJobLogsWithProcessedFileName(jobid, newFileName); string archivedfile = string.Empty; if (Directory.Exists(leadAdapterAndAccountMap.ArchivePath) && System.IO.File.Exists(localFilePath)) { archivedfile = Path.Combine(leadAdapterAndAccountMap.ArchivePath, newFileName); File.Move(localFilePath, archivedfile); } else if (File.Exists(localFilePath)) { File.Delete(localFilePath); } bool isFolderExist = ftpManager.CreateFTPDirectory(leadAdapterAndAccountMap.RequestGuid); if (isFolderExist) { ftpManager.MoveFile(leadAdapterAndAccountMap.RequestGuid, fileName, archivedfile, jobid); } else { ftpManager.Delete(leadAdapterAndAccountMap.RequestGuid, string.Empty, new List <string> { fileName }); } } catch (IndexOutOfRangeException indexExc) { Logger.Current.Error("Index out of range exception while accessing jobid and filename, account name : " + leadAdapterAndAccountMap.AccountName, indexExc); var fileExtension = Path.GetExtension(localFilePath); var newFileName = Guid.NewGuid() + fileExtension; string archivedfile = string.Empty; archivedfile = Path.Combine(leadAdapterAndAccountMap.ArchivePath, newFileName); File.Move(localFilePath, archivedfile); //These are old files continue; } } Logger.Current.Informational("Files processed succcessfully for account : " + leadAdapterAndAccountMap.AccountName + " count of files : " + Files.LongLength); } }