Exemple #1
0
        public IHttpActionResult GetCompanyById()
        {
            int      companyId  = Global.GetCompanyIdFromToken();
            RedisKey cacheKey   = "external_company_" + companyId;
            string   cacheValue = null;// RedisCacheHelper.GetValueByKey(cacheKey);

            if (cacheValue == null)
            {
                try
                {
                    CompanyModel model = new CompanyModel();
                    //RedisCacheHelper.SetKeyValue(cacheKey, JsonConvert.SerializeObject(company));
                    return(Content(HttpStatusCode.OK, model.GetCompanyByIdForExternal(UserToken.CompanyId)));
                }
                catch (CDSException cdsEx)
                {
                    return(Content(HttpStatusCode.BadRequest, CDSException.GetCDSErrorMessageByCode(cdsEx.ErrorId)));
                }
                catch (Exception ex)
                {
                    return(Content(HttpStatusCode.InternalServerError, ex));
                }
            }
            else
            {
                return(Ok(new JavaScriptSerializer().Deserialize <Object>(cacheValue)));
            }
        }