public void SetCRMAccount(CRMAccount crmAccount) { if (crmAccount != null) { m_crmAccount = crmAccount; SetStatusMessage(UPDATE_TEXT, false); m_crmType.SelectedIndex = m_crmType.Items.IndexOf(m_crmType.Items.Single(x => ((TextBlock)x).Text == crmAccount.CRMAccountType.ToString())); m_crmURL.Text = crmAccount.URL; m_crmUsername.Text = crmAccount.Username; m_crmPassword.Text = crmAccount.Password; m_deleteButton.IsEnabled = true; } else { m_crmAccount = null; SetStatusMessage(ADD_TEXT, false); m_crmURL.Text = String.Empty; m_crmUsername.Text = String.Empty; m_crmPassword.Text = String.Empty; m_deleteButton.IsEnabled = false; } }
public AccountDetailsViewModel(CRMAccount account) : this() { Id = account.Id; Title = account.Title; Industry = account.Industry; EmployeeCount = account.EmployeeCount; FoundedOn = account.FoundedOn; Email = account.Email; PhoneNo = account.PhoneNo; SecondaryEmail = account.SecondaryEmail; OfficePhone = account.OfficePhone; Website = account.Website; Facebook = account.Facebook; Twitter = account.Twitter; GooglePlus = account.GooglePlus; LinkedIn = account.LinkedIn; City = account.City; Country = account.Country; Address = account.Address; CommunicationAddress = account.CommunicationAddress; Expertise = account.Expertise; Description = account.Description; AssignedToUserId = account.AssignedToEmployeeId; AssignedToUser = account.AssignedToEmployee; ParentId = account.ParentId; Parent = account.Parent; }
public ActionResult Create(CRMAccount cRMAccount) { if (ModelState.IsValid) { cRMAccount.CreatedByUserId = WebUser.Id; _crmAccountRepository.Create(cRMAccount); _unitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(cRMAccount)); }
private string Validate(CRMAccount crmAccount) { var validationResults = new List <ValidationResult>(); var validationContext = new ValidationContext(crmAccount, null, null); Validator.TryValidateObject(crmAccount, validationContext, validationResults); crmAccount.ValidationErrors.Clear(); if (validationResults.Count > 0) { return(validationResults[0].ErrorMessage); } else { // Do any other client side validation required. return(null); } }
private void Submit(object sender, System.Windows.RoutedEventArgs e) { if (m_crmAccount == null) { CRMAccount crmAccount = new CRMAccount() { ID = Guid.Empty.ToString(), // Will be set in the manager. Owner = "None", // Will be set in the manager. CRMTypeID = Enum.Parse(typeof(CRMAccountTypes), ((TextBlock)m_crmType.SelectedValue).Text, true).GetHashCode(), URL = m_crmURL.Text, Username = m_crmUsername.Text, Password = m_crmPassword.Text, }; string validationError = Validate(crmAccount); if (validationError != null) { SetErrorMessage(validationError); } else { Add(crmAccount); } } else { m_crmAccount.CRMTypeID = Enum.Parse(typeof(CRMAccountTypes), ((TextBlock)m_crmType.SelectedValue).Text, true).GetHashCode(); m_crmAccount.URL = m_crmURL.Text; m_crmAccount.Username = m_crmUsername.Text; m_crmAccount.Password = m_crmPassword.Text; string validationError = Validate(m_crmAccount); if (validationError != null) { SetErrorMessage(validationError); } else { Update(m_crmAccount); } } }
public ActionResult Edit(CRMAccount cRMAccount) { if (ModelState.IsValid) { var selectedAccount = _crmAccountRepository.Get(cRMAccount.Id); if (selectedAccount != null) { selectedAccount.Title = cRMAccount.Title; selectedAccount.Industry = cRMAccount.Industry; selectedAccount.EmployeeCount = cRMAccount.EmployeeCount; selectedAccount.FoundedOn = cRMAccount.FoundedOn; selectedAccount.Email = cRMAccount.Email; selectedAccount.PhoneNo = cRMAccount.PhoneNo; selectedAccount.SecondaryEmail = cRMAccount.SecondaryEmail; selectedAccount.OfficePhone = cRMAccount.OfficePhone; selectedAccount.Website = cRMAccount.Website; selectedAccount.Facebook = cRMAccount.Facebook; selectedAccount.Twitter = cRMAccount.Twitter; selectedAccount.GooglePlus = cRMAccount.GooglePlus; selectedAccount.LinkedIn = cRMAccount.LinkedIn; selectedAccount.City = cRMAccount.City; selectedAccount.Country = cRMAccount.Country; selectedAccount.Address = cRMAccount.Address; selectedAccount.CommunicationAddress = cRMAccount.CommunicationAddress; selectedAccount.Expertise = cRMAccount.Expertise; selectedAccount.Description = cRMAccount.Description; selectedAccount.AssignedToEmployeeId = cRMAccount.AssignedToEmployeeId; selectedAccount.ParentId = cRMAccount.ParentId; selectedAccount.UpdatedByUserId = WebUser.Id; _crmAccountRepository.Update(selectedAccount); _unitOfWork.Commit(); return(RedirectToAction("Index")); } } return(View(cRMAccount)); }
public CRMAccountModel(CRMAccount contact) { Id = contact.Id; if (contact.Parent != null) { Parent = contact.Parent.Title; } if (contact.AssignedToEmployee != null) { AssignedToEmployee = contact.AssignedToEmployee.User.Person.Name; } ParentId = contact.ParentId; AssignedToEmployeeId = contact.AssignedToEmployeeId; PhoneNo = contact.PhoneNo; Email = contact.Email; CreatedOn = contact.CreatedOn; Title = contact.Title; Industry = contact.Industry; EmployeeCount = contact.EmployeeCount; FoundedOn = contact.FoundedOn; Email = contact.Email; SecondaryEmail = contact.SecondaryEmail; OfficePhone = contact.OfficePhone; Website = contact.Website; Facebook = contact.Facebook; LinkedIn = contact.LinkedIn; Twitter = contact.Twitter; Country = contact.Country; GooglePlus = contact.GooglePlus; City = contact.City; Description = contact.Description; Country = contact.Country; Address = contact.Address; CommunicationAddress = contact.CommunicationAddress; Expertise = contact.Expertise; }
public bool Convert(bool createAccount, bool createPotential, int id, int assignedToUserId, int?categoryId, double?expectedAmount, DateTime?expectedCloseDate, string description, DateTime?enquiredOn, int salesStage, int createdByUserId) { var selectedLead = _crmLeadRepository.GetBy(l => l.Id == id, "Person"); if (selectedLead != null) { CRMAccount selectedOrganization = null; if (createAccount) { // Create the Account First var organization = selectedLead.Person.Organization; if (!string.IsNullOrEmpty(organization)) { selectedOrganization = _crmAccountRepository.GetBy(a => a.Title == organization); if (selectedOrganization == null) { selectedOrganization = new CRMAccount { Title = organization, EmployeeCount = EmployeeCount.One2Ten, AssignedToEmployeeId = assignedToUserId, CreatedByUserId = createdByUserId }; _crmAccountRepository.Create(selectedOrganization); _unitOfWork.Commit(); } } } // Create Contact var contact = new CRMContact { PersonId = selectedLead.PersonId, CreatedByUserId = createdByUserId }; // Assign the account Id if (selectedOrganization != null) { contact.ParentAccountId = selectedOrganization.Id; } _crmContactRepository.Create(contact); _unitOfWork.Commit(); if (createPotential) { // Create the Potential var potential = new CRMPotential { CategoryId = categoryId, ExpectedAmount = expectedAmount, ExpectedCloseDate = expectedCloseDate, Description = description, EnquiredOn = enquiredOn, SalesStageId = salesStage, AssignedToUserId = assignedToUserId, ContactId = contact.Id, CreatedByUserId = createdByUserId }; _crmPotentialRepository.Create(potential); _unitOfWork.Commit(); // Move all Lead Technologies to Potential Technologies var technologies = _crmLeadTechnologyMapRepository.GetAllBy(m => m.LeadId == selectedLead.Id).ToList(); foreach (var technology in technologies) { var technologyMap = new CRMPotentialTechnologyMap { PotentialId = potential.Id, TechnologyId = technology.TechnologyId }; _crmPotentialTechnologyMapRepository.Create(technologyMap); } // Move all Lead Activities to Potential Activities var activities = _crmLeadActivityRepository.GetAllBy(m => m.CRMLeadId == selectedLead.Id).ToList(); foreach (var activity in activities) { var potentialActivity = new CRMPotentialActivity { CRMPotentialId = potential.Id, Title = activity.Title, Comment = activity.Comment, CreatedOn = activity.CreatedOn, CreatedByUserId = createdByUserId }; _crmPotentialActivityRepository.Create(potentialActivity); } _unitOfWork.Commit(); } // Delete the Lead _crmLeadService.Delete(id); return(true); } return(false); }
public ActionResult Update(CRMAccountModel cRMAccount) { ApiResult <CRMAccount> apiResult; if (ModelState.IsValid) { if (cRMAccount.Id > 0) { apiResult = TryExecute(() => { var selectedAccount = _crmAccountRepository.Get(cRMAccount.Id); if (selectedAccount != null) { selectedAccount.Title = cRMAccount.Title; selectedAccount.Industry = cRMAccount.Industry; selectedAccount.EmployeeCount = cRMAccount.EmployeeCount; selectedAccount.FoundedOn = cRMAccount.FoundedOn; selectedAccount.Email = cRMAccount.Email; selectedAccount.PhoneNo = cRMAccount.PhoneNo; selectedAccount.SecondaryEmail = cRMAccount.SecondaryEmail; selectedAccount.OfficePhone = cRMAccount.OfficePhone; selectedAccount.Website = cRMAccount.Website; selectedAccount.Facebook = cRMAccount.Facebook; selectedAccount.Twitter = cRMAccount.Twitter; selectedAccount.GooglePlus = cRMAccount.GooglePlus; selectedAccount.LinkedIn = cRMAccount.LinkedIn; selectedAccount.City = cRMAccount.City; selectedAccount.Country = cRMAccount.Country; selectedAccount.Address = cRMAccount.Address; selectedAccount.CommunicationAddress = cRMAccount.CommunicationAddress; selectedAccount.Expertise = cRMAccount.Expertise; selectedAccount.Description = cRMAccount.Description; selectedAccount.AssignedToEmployeeId = cRMAccount.AssignedToEmployeeId; selectedAccount.ParentId = cRMAccount.ParentId; selectedAccount.UpdatedByUserId = WebUser.Id; _crmAccountRepository.Update(selectedAccount); _unitOfWork.Commit(); } return(selectedAccount); }, "CRM Account updated sucessfully"); } else { apiResult = TryExecute(() => { var crmAccount = new CRMAccount { Title = cRMAccount.Title, Industry = cRMAccount.Industry, EmployeeCount = cRMAccount.EmployeeCount, FoundedOn = cRMAccount.FoundedOn, Email = cRMAccount.Email, PhoneNo = cRMAccount.PhoneNo, SecondaryEmail = cRMAccount.SecondaryEmail, OfficePhone = cRMAccount.OfficePhone, Website = cRMAccount.Website, Facebook = cRMAccount.Facebook, Twitter = cRMAccount.Twitter, GooglePlus = cRMAccount.GooglePlus, LinkedIn = cRMAccount.LinkedIn, City = cRMAccount.City, Country = cRMAccount.Country, Address = cRMAccount.Address, CommunicationAddress = cRMAccount.CommunicationAddress, Expertise = cRMAccount.Expertise, Description = cRMAccount.Description, AssignedToEmployeeId = cRMAccount.AssignedToEmployeeId, ParentId = cRMAccount.ParentId, CreatedByUserId = WebUser.Id, }; _crmAccountRepository.Create(crmAccount); _unitOfWork.Commit(); return(crmAccount); }, "CRM Account created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <CRMAccount>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }