Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectToLoginIfAnonymous();

            if (!IsPostBack)
            {
                HideControlsBasedOnAccess(ServiceContext, Contact);
            }

            var cases = new CaseAccess().CasesForCurrentUser.Cast <Incident>();

            var status = StatusDropDown.Text;

            var casesByStatus = string.Equals(status, "Active", StringComparison.InvariantCulture)
                                ? cases.Where(c => c.StateCode == (int)Enums.IncidentState.Active)
                                : cases.Where(c => c.StateCode != (int)Enums.IncidentState.Active);

            var casesByCustomer = string.Equals(CustomerFilter.Text, "My", StringComparison.InvariantCulture)
                                ? casesByStatus.Where(c => c.CustomerId.Id == Contact.ContactId)
                                : string.Equals(CustomerFilter.Text, "My Company's", StringComparison.InvariantCulture)
                                        ? casesByStatus.Where(c => c.CustomerId.Id != Contact.ContactId)
                                        : casesByStatus;

            if (casesByCustomer.Count() == 0)
            {
                return;
            }

            CaseList.DataKeyNames     = new[] { "incidentid" };
            CaseList.DataSource       = casesByCustomer.ToDataTable(XrmContext);
            CaseList.ColumnsGenerator = new CrmSavedQueryColumnsGenerator("Cases Web View");
            CaseList.DataBind();
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataAdapter = new UserCasesDataAdapter(new PortalContextDataAdapterDependencies(Portal, PortalName, Request.RequestContext));

            if (!IsPostBack)
            {
                CaseDeflection.Visible = CaseDeflectionEnabled;
                CreateCase.Visible     = DirectCaseCreationEnabled;

                var permissionScopes = dataAdapter.SelectPermissionScopes();

                HideControlsBasedOnAccess(permissionScopes);
                PopulateCustomerFilter(permissionScopes);
            }

            var cases = GetCases(dataAdapter);

            var columnsGenerator = new SavedQueryColumnsGenerator(XrmContext, "incident", "Cases Web View");

            CaseList.DataKeyNames     = new[] { "incidentid" };
            CaseList.DataSource       = columnsGenerator.ToDataTable(cases.Select(c => c.Entity), "o", CultureInfo.InvariantCulture);
            CaseList.ColumnsGenerator = columnsGenerator;
            CaseList.DataBind();
        }