Exemple #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);
        }
Exemple #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));
        }
Exemple #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();
            }
        }