Пример #1
0
        public string Organization2(string id)
        {
            int           recordId      = 0;
            var           entity        = new Organization();
            bool          skippingCache = FormHelper.GetRequestKeyValue("skipCache", false);
            List <string> messages      = new List <string>();

            if (int.TryParse(id, out recordId))
            {
                entity = OrganizationServices.GetDetail(recordId, skippingCache);
            }
            else if (ServiceHelper.IsValidCtid(id, ref messages))
            {
                entity = OrganizationServices.GetDetailByCtid(id, skippingCache);
            }
            else
            {
                return("ERROR - Invalid request. Either provide a CTID which starts with 'ce-' or the number. ");
            }
            //HttpContext.Server.ScriptTimeout = 300;

            if (entity.Id == 0)
            {
                return("ERROR - Invalid request - the record was not found. ");
            }
            ActivityServices.SiteActivityAdd("Organization", "View", "Detail", string.Format("User viewed Organization: {0} ({1})", entity.Name, entity.Id), 0, 0, recordId);

            string jsonoutput = JsonConvert.SerializeObject(entity, JsonHelper.GetJsonSettings());

            HttpContext.Current.Response.ContentType     = "application/json";
            HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            return(jsonoutput);
        }
Пример #2
0
        //

        public ActionResult Organization(string id, string name = "")
        {
            //Organization entity = new Organization();
            int           orgId         = 0;
            var           entity        = new Organization();
            string        refresh       = Request.Params["refresh"];
            bool          skippingCache = FormHelper.GetRequestKeyValue("skipCache", false);
            List <string> messages      = new List <string>();

            if (int.TryParse(id, out orgId))
            {
                entity = OrganizationServices.GetDetail(orgId, skippingCache);
            }
            else if (ServiceHelper.IsValidCtid(id, ref messages))
            {
                entity = OrganizationServices.GetDetailByCtid(id, skippingCache);
            }
            else
            {
                SetPopupErrorMessage("ERROR - Enter the ctid which starts with 'ce' or Enter the id ");
                return(RedirectToAction("Index", "Home"));
            }
            if (entity.Id == 0)
            {
                SetPopupErrorMessage("ERROR - the requested Organization record was not found ");
                return(RedirectToAction("Index", "Home"));
            }
            ActivityServices.SiteActivityAdd("Organization", "View", "Detail", string.Format("User viewed Organization: {0} ({1})", entity.Name, entity.Id), 0, 0, orgId);

            return(View("~/Views/Detail/Detail.cshtml", entity));
        }
Пример #3
0
        public void OrganizationOld(string id)
        {
            int           recordId      = 0;
            var           entity        = new Organization();
            bool          skippingCache = FormHelper.GetRequestKeyValue("skipCache", false);
            List <string> messages      = new List <string>();

            if (int.TryParse(id, out recordId))
            {
                entity = OrganizationServices.GetDetail(recordId, skippingCache);
            }
            else if (ServiceHelper.IsValidCtid(id, ref messages))
            {
                entity = OrganizationServices.GetDetailByCtid(id, skippingCache);
            }
            else
            {
                messages.Add("ERROR - Invalid request. Either provide a CTID which starts with 'ce-' or the number. ");
            }
            //HttpContext.Server.ScriptTimeout = 300;

            if (entity.Id == 0)
            {
                messages.Add("ERROR - Invalid request - the record was not found. ");
            }
            if (messages.Any())
            {
                SendResponse(messages);
                //HttpContext.Current.Response.Clear();
                //HttpContext.Current.Response.AppendHeader( "Access-Control-Allow-Origin", "*" );
                //HttpContext.Current.Response.ContentType = "application/json";
                //HttpContext.Current.Response.Write( messages );
                //HttpContext.Current.Response.End();
            }
            else
            {
                //map to new
                ActivityServices.SiteActivityAdd("Organization", "View", "Detail", string.Format("User viewed Organization: {0} ({1})", entity.Name, entity.Id), 0, 0, recordId);

                string jsonoutput = JsonConvert.SerializeObject(entity, JsonHelper.GetJsonSettings());

                SendResponse(jsonoutput);
                //HttpContext.Current.Response.Clear();
                //HttpContext.Current.Response.AppendHeader( "Access-Control-Allow-Origin", "*" );
                //HttpContext.Current.Response.ContentType = "application/json";
                //HttpContext.Current.Response.Write( jsonoutput );
                //HttpContext.Current.Response.End();
            }
        }
Пример #4
0
        public ActionResult V3()
        {
            var    vm = new CompareItemSummary();
            string credentialCompare = "";
            string orgCompare        = "";
            string asmtCompare       = "";
            string loppCompare       = "";

            var lists = GetSessionItems();

            foreach (var item in lists)
            {
                switch (item.Type)
                {
                case "credential":
                    var entity = CredentialServices.GetCredentialForCompare(item.Id);
                    vm.Credentials.Add(entity);
                    ActivityServices.SiteActivityAdd("Credential", "View", "Compare", string.Format("User doing compare on Credential: {0} ({1})", entity.Name, entity.Id), 0, 0, entity.Id);
                    break;

                case "organization":
                    var org = OrganizationServices.GetDetail(item.Id);
                    vm.Organizations.Add(org);
                    ActivityServices.SiteActivityAdd("Organization", "View", "Compare", string.Format("User doing compare on Organization: {0} ({1})", org.Name, org.Id), 0, 0, org.Id);
                    break;

                case "assessment":
                    var asmt = AssessmentServices.GetDetail(item.Id);
                    vm.Assessments.Add(asmt);
                    ActivityServices.SiteActivityAdd("Assessment", "View", "Compare", string.Format("User doing compare on Assessment: {0} ({1})", asmt.Name, asmt.Id), 0, 0, asmt.Id);
                    break;

                case "learningopportunity":
                    var lopp = LearningOpportunityServices.GetDetail(item.Id);
                    vm.LearningOpportunities.Add(lopp);
                    ActivityServices.SiteActivityAdd("LearningOpportunity", "View", "Compare", string.Format("User doing compare on Learning opportunity: {0} ({1})", lopp.Name, lopp.Id), 0, 0, lopp.Id);
                    break;

                default:
                    break;
                }
            }

            return(View("CompareV3", vm));
        }