public ActionResult Index() { ReassignModel reassignModel = new ReassignModel() { IsIndexPage = true }; if (SessionManager.Exists(MESSAGE_SESSION_KEY)) { SessionManager.Get<ReassignModel>(MESSAGE_SESSION_KEY, out reassignModel); SessionManager.Clear(MESSAGE_SESSION_KEY); } return View("Index", reassignModel); }
private ReassignModel GetDataModel(bool isCustomer, bool oneOrManyCustomerProspects, string searchValue, bool isSearchValueLetter) { List<FirmInstitution> lstFirmInstitutions = new List<FirmInstitution>(); List<CustomerProspect> lstCustomerProspects = new List<CustomerProspect>(); List<User> lstFilterAdvisers = new List<User>(); List<User> lstReassignAdvisers = new List<User>(); Guid selectedFirmInSession = Guid.Empty; Guid? selectedUserInSession = Guid.Empty; SessionManager.Get<Guid>(UserBL.SelectedFirmIdSessionKey, out selectedFirmInSession); SessionManager.Get<Guid?>(UserBL.SelectedUserIdSessionKey, out selectedUserInSession); Guid selectedUser = (selectedUserInSession != null) ? selectedUserInSession.Value : SessionManager.GetUserSession().idUser; //Clients / Prospects list if (oneOrManyCustomerProspects) { lstCustomerProspects = this.GetCustomerProspects(isCustomer, searchValue, isSearchValueLetter, selectedUser); } //Advisers list and FirmInstitution list this.GetDataToPopulateDropDowns(selectedUser, out lstFilterAdvisers, out lstFirmInstitutions); //Copy FilterAdvisers to ReassingAdvisers lstFilterAdvisers.ForEach(user => { lstReassignAdvisers.Add(user); }); //Set first element for adviser dropdown lstFilterAdvisers.Insert(0, new User() { idUser = Guid.Empty, UserName = languageData.GetContent("reaffec_tous_les_utilisateurs") }); lstReassignAdvisers.Insert(0, new User() { idUser = Guid.Empty, UserName = languageData.GetContent("reaffec_select_un_conseiller") }); ReassignModel reassignModel = new ReassignModel() { IsIndexPage = false, FilterAdvisers = lstFilterAdvisers, ReassignAdvisers = lstReassignAdvisers, FirmInstitutions = lstFirmInstitutions, OneOrManyCustomerProspects = oneOrManyCustomerProspects, CustomerProspectsList = lstCustomerProspects, IsCustomer = isCustomer, ShowFilterAdvisersList = true, //always true for this module SelectedAdviserId = selectedUser, SelectedFirmId = selectedFirmInSession }; //Modulte title if (isCustomer) { if (oneOrManyCustomerProspects) { reassignModel.ModuleTitle = languageData.GetContent("reaffecter_client_selectionne"); } else { reassignModel.ModuleTitle = languageData.GetContent("reaffecter_tous_clients"); } } else { if (oneOrManyCustomerProspects) { reassignModel.ModuleTitle = languageData.GetContent("reaffecter_prospect_selectionne"); } else { reassignModel.ModuleTitle = languageData.GetContent("reaffecter_tous_prospects"); } } return reassignModel; }
public ActionResult SaveReassignToDataBase(bool oneOrMany = true, bool isCustomer = true) { string error = string.Empty; try { if (oneOrMany) { if (this.CustomerProspectsToReassign.Count == 0) { error = languageData.GetContent("reaffec_choisir_client_prospect"); } else { CustomerProspectBL.ReassignSomeCustomerProspects(this.CustomerProspectsToReassign); } } else { Guid idUserAdviserSource = new Guid(Request.Form["ddlAdvisersSource"]); Guid idUserAdviserDest = new Guid(Request.Form["ddlAdvisersDest"]); if (idUserAdviserSource == Guid.Empty || idUserAdviserDest == Guid.Empty) { error = languageData.GetContent("reaffec_choisir_conseiller"); } else { CustomerProspectBL.ReassignAllCustomerProspects(idUserAdviserSource, idUserAdviserDest, isCustomer); } } } catch (Exception ex) { Upsilab.Business.Log.Log.AppendException(ex); error = string.Format("{0} : {1}", languageData.GetContent("reaffec_exception"), ex.Message); } finally { //Clear session this.CustomerProspectsToReassign.Clear(); } //Redirect to index and show error or success string messageContent = string.Empty; string messageTitle = string.Empty; if (!string.IsNullOrEmpty(error)) { messageContent = error; messageTitle = languageData.GetContent("reaffec_erreur_titre"); } else { messageContent = languageData.GetContent("reaffec_success_message"); messageTitle = languageData.GetContent("reaffec_success_titre"); } ReassignModel reassignModel = new ReassignModel() { IsIndexPage = true, MessageContent = messageContent, MessageTitle = messageTitle }; SessionManager.Set<ReassignModel>(MESSAGE_SESSION_KEY, reassignModel); //clear it in index page return RedirectToAction("Index"); }
public ActionResult Selection(ReassignModel reassignModel) { Guid? _selectedUser = null; Guid? _idCurrentFirm = null; //Clear only selected Firm session if (SessionManager.Exists(UserBL.SelectedFirmIdSessionKey)) { SessionManager.Clear(UserBL.SelectedFirmIdSessionKey); } //Selection sur le combobox user if (!string.IsNullOrEmpty(Request.Params["idCurrentUser"])) { _selectedUser = Guid.Parse(Request.Params["idCurrentUser"]); SessionManager.Set<Guid?>(UserBL.SelectedUserIdSessionKey, _selectedUser); if (!string.IsNullOrEmpty(Request.Params["txtSelectedFirmGUID"])) { _idCurrentFirm = new Guid(Request.Params["txtSelectedFirmGUID"]); SessionManager.Set<Guid?>(UserBL.SelectedFirmIdSessionKey, _idCurrentFirm); } } if (!string.IsNullOrEmpty(Request.Params["txtSelectedFirmGUID"])) { _idCurrentFirm = new Guid(Request.Params["txtSelectedFirmGUID"]); SessionManager.Set<Guid?>(UserBL.SelectedFirmIdSessionKey, _idCurrentFirm); } //Filter by letter ? string searchValue = string.Empty; bool isLetter = false; if (Request.Params["lettre"] != null) { searchValue = Request.Params["lettre"].ToString(); isLetter = true; ViewBag.Script = string.Format("if($(_anchorObj).text()=='{0}') {1}", searchValue, "{ $(_anchorObj).removeClass('lettreGlossaire').addClass('lettreGlossaireOn');}"); } //TODO : search value from textbox ??? bool isCustomer = reassignModel.IsCustomer; bool oneOrManyCustomerProspects = true; reassignModel = this.GetDataModel(isCustomer, oneOrManyCustomerProspects, searchValue, isLetter); return View("Index", reassignModel); }