public JsonResult UpdateUserView(string viewId, string viewPref) { var userView = new UserViewDto { UserID = _authUser.UserId, ClientID = _authUser.ClientId, UserViewID = Int32.Parse(viewId), ViewName = "Default", View = viewPref }; var nList = _userBl.UpdateUserView(userView); var userAdded = new UserHandlerModel(); if (nList > 0) { userAdded.MgUserId = nList; userAdded.StrMessage = "Updated"; } else if (nList == 0) { userAdded.MgUserId = nList; userAdded.StrMessage = "Error"; } return(Json(userAdded, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateOppStatusField(int cdfId, string field, string newValue) { try { bool isValid = true; if (field.Equals("Order")) { var validValue = Int32.Parse(newValue); isValid = _oppStatusBL.ValidateOrder(_authUser.ClientId, cdfId, validValue); } if (field.Equals("DefaultB")) { if (newValue.ToUpper().Equals("TRUE")) { newValue = "Y"; } else { newValue = "N"; } field = "Default"; } if (field.Equals("StageType")) { //if (newValue.ToUpper().Equals("TRUE")) //{ //newValue = "Y"; //} //else //{ newValue = "N"; } //field = "ArchivedStatus"; } var userEdit = new UserHandlerModel(); if (isValid) { var nList = _oppStatusBL.UpdateOppStatusField(cdfId, field, newValue); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } } else { userEdit.MgUserId = -2; userEdit.StrMessage = "Error"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateOppStatusDefault(int cdfId) { try { var userEdit = new UserHandlerModel(); var nList = _oppStatusBL.UpdateOppStatusDefault(_authUser.ClientId, cdfId); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } else { userEdit.MgUserId = -2; userEdit.StrMessage = "Error"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult SetRequestedEmail(string userIdList) { try { var requested = new UserHandlerModel { MgUserId = 0, StrMessage = "There was an error" }; var nList = _userBl.UpdateUserEmailSent(userIdList); requested.StrMessage = nList; if (!string.IsNullOrEmpty(nList)) { requested.MgUserId = 1; } return(Json(requested, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteUserRows(string userIdList) { try { var userDeleted = new UserHandlerModel { MgUserId = 0, StrMessage = "There was an error" }; var nList = _userBl.DeleteUsers(userIdList); userDeleted.StrMessage = nList; if (!string.IsNullOrEmpty(nList)) { userDeleted.MgUserId = 1; } return(Json(userDeleted, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateUserManager(UserDto user) { try { var userEdit = new UserHandlerModel(); if (user.ManagerUserID != user.UserId) { var nList = _userBl.UpdateUserManager(user.UserId, user.ManagerUserID.Value); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } } else { userEdit.MgUserId = 0; userEdit.StrMessage = "Error: You cannot be your own manager"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddClientDefinedField(ClientDefinedFieldModel cdfModel) { Mapper.CreateMap <ClientDefinedFieldModel, ClientDefinedFieldDto>(); var cdfDto = Mapper.Map <ClientDefinedFieldModel, ClientDefinedFieldDto>(cdfModel); //Mapper.AssertConfigurationIsValid(); cdfDto.ClientID = _authUser.ClientId; var cdfs = _clientDefinedFieldBL.GetClientDefinedFields(cdfDto.ClientID, cdfDto.Table, cdfDto.Field); var userAdded = new UserHandlerModel(); if (cdfs.Count > 0) { userAdded.MgUserId = -2; userAdded.StrMessage = "Error"; } else { var nList = _clientDefinedFieldBL.AddClientDefinedField(cdfDto); if (nList > 0) { userAdded.MgUserId = nList; userAdded.StrMessage = "Added"; } } return(Json(userAdded, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteOppStatuses(string cdfIdList) { try { var userDeleted = new UserHandlerModel { MgUserId = 1, StrMessage = "Successful" }; var nList = _oppStatusBL.DeleteOppStatuses(cdfIdList); if (!string.IsNullOrEmpty(nList)) { userDeleted.StrMessage = nList;// userDeleted.MgUserId = 2; } return(Json(userDeleted, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult SaveNewUserView(string viewName, string viewPref) { var userView = new UserViewDto { UserID = _authUser.UserId, ClientID = _authUser.ClientId, View = viewPref, ViewName = viewName }; var nList = _userBl.SaveNewUserView(userView); var userAdded = new UserHandlerModel(); if (nList > 0) { userAdded.MgUserId = nList; userAdded.StrMessage = "Added"; } else if (nList == 0) { userAdded.MgUserId = nList; userAdded.StrMessage = "Cannot store more than 30 views"; } //else if (nList == -2) //{ // userAdded.MgUserId = nList; // userAdded.StrMessage = "There is already a view with this name"; //} return(Json(userAdded, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateUserField(int userId, string field, string newValue) { try { if (field.Equals("Administrator")) { if (newValue.ToUpper().Equals("TRUE")) { newValue = "Y"; } else { newValue = "N"; } } var nList = _userBl.UpdateUserField(userId, field, newValue); var userEdit = new UserHandlerModel(); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult UserViewDataGrid() { var displayViews = new List <UserHandlerModel>();; var viewPrefs = _userBl.GetUserViewsByUserAndClient(_authUser.ClientId, _authUser.UserId); foreach (UserViewDto u in viewPrefs) { var a = new UserHandlerModel { MgUserId = u.UserViewID, StrMessage = u.ViewName }; displayViews.Add(a); } return(Json(displayViews, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateCDFField(int cdfId, string field, string newValue) { try { bool isValid = true; if (field.Equals("Table") || field.Equals("Field")) { isValid = _clientDefinedFieldBL.ValidateFieldToUpdate(_authUser.ClientId, cdfId, field, newValue); } var userEdit = new UserHandlerModel(); if (isValid) { var nList = _clientDefinedFieldBL.UpdateCDFField(cdfId, field, newValue); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } } else { userEdit.MgUserId = -2; userEdit.StrMessage = "Error"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; if (e.InnerException != null) { error.StrMessage += e.InnerException.Message; } return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddOpportunityRow(OpportunityModel opportunity) { Mapper.CreateMap <OpportunityModel, OpportunityDto>() .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore()) .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore()) .ForMember(dest => dest.CloudLastUpdById, opt => opt.Ignore()) .ForMember(dest => dest.OppStatus, opt => opt.MapFrom(src => src.OppStatusId)) .ForMember(dest => dest.QuoteIDMainSite, opt => opt.Ignore()) .ForMember(dest => dest.SDALastUpdBy, opt => opt.Ignore()) .ForMember(dest => dest.SDALastUpdDT, opt => opt.Ignore()) .ForMember(dest => dest.LoginInfo, opt => opt.Ignore()) .ForMember(dest => dest.OpportunityTable, opt => opt.Ignore()) .ForMember(dest => dest.CRMXrefDefinition, opt => opt.Ignore()) .ForMember(dest => dest.CreateBy, opt => opt.Ignore()) .ForMember(dest => dest.Quotes, opt => opt.Ignore()); var opportunityDto = Mapper.Map <OpportunityModel, OpportunityDto>(opportunity); //Mapper.AssertConfigurationIsValid(); opportunityDto.ClientID = _authUser.ClientId; opportunityDto.CloudLastUpdById = _authUser.UserId; opportunityDto.CloudLastUpdDT = DateTime.Today.ToString(CultureInfo.InvariantCulture); opportunityDto.SDALastUpdBy = 0; opportunityDto.SDALastUpdDT = DateTime.Today.ToString(CultureInfo.InvariantCulture); var nList = _opportunityBl.AddOpportunity(opportunityDto); var userAdded = new UserHandlerModel(); if (nList > 0) { var newOpp = _opportunityBl.GetNonDeletedOpportunityByClientIDAndOppID(_authUser.ClientId, nList); userAdded.MgUserId = nList; userAdded.StrMessage = newOpp.CRMOppID; } else { userAdded.StrMessage = opportunityDto.ToString(); } return(Json(userAdded, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateOpportunityRow(OpportunityModel opportunity) { try { Mapper.CreateMap <OpportunityModel, OpportunityDto>() .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore()) .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore()) .ForMember(dest => dest.CloudLastUpdById, opt => opt.Ignore()) .ForMember(dest => dest.OppStatus, opt => opt.MapFrom(src => src.OppStatusId)) .ForMember(dest => dest.QuoteIDMainSite, opt => opt.Ignore()) .ForMember(dest => dest.SDALastUpdBy, opt => opt.Ignore()) .ForMember(dest => dest.LoginInfo, opt => opt.Ignore()) .ForMember(dest => dest.OpportunityTable, opt => opt.Ignore()) .ForMember(dest => dest.CRMXrefDefinition, opt => opt.Ignore()) .ForMember(dest => dest.CreateBy, opt => opt.Ignore()) .ForMember(dest => dest.Quotes, opt => opt.Ignore()); var opportunityDto = Mapper.Map <OpportunityModel, OpportunityDto>(opportunity); //Mapper.AssertConfigurationIsValid(); opportunityDto.CloudLastUpdById = _authUser.UserId; opportunityDto.ClientID = _authUser.ClientId; var nList = _opportunityBl.UpdateOpportunityById(opportunityDto); var userEdit = new UserHandlerModel(); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddUserRow(UserDto user) { user.ClientId = _authUser.ClientId; var tempPwd = user.Password; user.Password = Utils.Encrypt(tempPwd); if (user.ManagerUserID == 0) { user.ManagerUserID = null; } user.CloudLastUpdBy = _authUser.UserId; var nList = _userBl.AddUser(user); var userAdded = new UserHandlerModel { StrMessage = "There was an error" }; userAdded.MgUserId = nList; userAdded.StrMessage = tempPwd; return(Json(userAdded, JsonRequestBehavior.AllowGet)); }
public JsonResult AddOppStatus(OppStatusModel cdfModel) { try { Mapper.CreateMap <OppStatusModel, OppStatusDto>() .ForMember(dest => dest.Default, opt => opt.Ignore()); var cdfDto = Mapper.Map <OppStatusModel, OppStatusDto>(cdfModel); //Mapper.AssertConfigurationIsValid(); cdfDto.ClientID = _authUser.ClientId; cdfDto.Default = (cdfModel.DefaultB ? "Y" : "N"); var cdfs = _oppStatusBL.AddOppStatus(cdfDto); var userAdded = new UserHandlerModel { MgUserId = 0, StrMessage = "There was an error" }; if (cdfs != 0) { userAdded.MgUserId = cdfs; userAdded.StrMessage = "Added"; } return(Json(userAdded, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; if (e.InnerException != null) { error.StrMessage += e.InnerException.Message; } return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteOpportunityRow(int opportunityId) { try { var userDeleted = new UserHandlerModel(); var nList = _opportunityBl.DeleteOpportunity(opportunityId); if (nList > 0) { userDeleted.StrMessage = "Id:" + opportunityId + " was deleted successfully"; userDeleted.MgUserId = 1; } return(Json(userDeleted, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateQuoteRollup(int opportunityID, string quoteID, string rollup) { try { var nList = _quoteBl.UpdateQuoteRollup(opportunityID, quoteID, rollup); var userEdit = new UserHandlerModel(); if (nList > 0) { userEdit.MgUserId = 1; userEdit.StrMessage = "Updated"; } return(Json(userEdit, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteQuotes(string quoteIdList) { try { var userDeleted = new UserHandlerModel(); var nList = _quoteBl.DeleteQuotes(quoteIdList); if (nList > 0) { userDeleted.StrMessage = "Ids:" + quoteIdList + " were deleted successfully"; userDeleted.MgUserId = 1; } return(Json(userDeleted, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Reassign some quotes to an another opportunity /// </summary> /// <param name="quoteIdList">The quoteID's list to reassign</param> /// <param name="newOpportunityID">The new opportunity identifier.</param> /// <param name="newCRMOppID">The new CRM opp identifier.</param> /// <returns></returns> public JsonResult ReassignQuotes(string quoteIdList, int newOpportunityID, string newCRMOppID) { try { var userDeleted = new UserHandlerModel(); var nList = _quoteBl.ReassignQuotes(_authUser.ClientId, quoteIdList, newOpportunityID, newCRMOppID); if (nList > 0) { userDeleted.StrMessage = "Ids:" + quoteIdList + " were reassign successfully"; userDeleted.MgUserId = 1; } return(Json(userDeleted, JsonRequestBehavior.AllowGet)); } catch (Exception e) { var error = new UserHandlerModel { MgUserId = 0, StrMessage = "Session timeout: " + e.Message }; return(Json(error, JsonRequestBehavior.AllowGet)); } }
public JsonResult UserViews() { var displayViews = new List <UserHandlerModel>();; //displayViews.Add(new UserHandlerModel //{ // UserViewId = "Views", // StrMessage = " Views" //}); displayViews.Add(new UserHandlerModel { UserViewId = "SaveNewViewAs", StrMessage = "Save Current View as …" }); displayViews.Add(new UserHandlerModel { UserViewId = "SaveAsDefault", StrMessage = "Set Current View as Default" }); displayViews.Add(new UserHandlerModel { UserViewId = "DeleteViews", StrMessage = "Delete View(s) …" }); displayViews.Add(new UserHandlerModel { UserViewId = "StandardArchived", StrMessage = "Clear View" }); var viewPrefs = _userBl.GetAllUserViewsByUserAndClient(_authUser.ClientId, _authUser.UserId); var standardView = viewPrefs.Where(v => v.ViewName.ToUpper().Equals("STANDARD")).FirstOrDefault(); //if (standardView != null) //{ //displayViews.Add(new UserHandlerModel //{ // UserViewId = "Standard",//standardView.UserViewID.ToString(), // StrMessage = "Standard (Non-Archived)" //}); viewPrefs.Remove(standardView); //} //displayViews.Add(new UserHandlerModel //{ // UserViewId = "Archived",//standardView.UserViewID.ToString(), // StrMessage = "Standard (Archived)" //}); //displayViews.Add(new UserHandlerModel //{ // id = "StandardArchived",//standardView.UserViewID.ToString(), // text = "Standard (All)", // parentid = "Views" //}); var defaultView = viewPrefs.Where(v => v.ViewName.ToUpper().Equals("DEFAULT")).FirstOrDefault(); if (defaultView != null) { displayViews.Add(new UserHandlerModel { UserViewId = defaultView.UserViewID.ToString(), StrMessage = "Default" }); viewPrefs.Remove(defaultView); } foreach (UserViewDto u in viewPrefs) { var a = new UserHandlerModel { UserViewId = u.UserViewID.ToString(), StrMessage = u.ViewName }; displayViews.Add(a); } return(Json(displayViews, JsonRequestBehavior.AllowGet)); }