예제 #1
0
        //
        // GET: /Home/
        public ActionResult Index(bool encrypt = false)
        {
            ServiceResponse r = new ServiceResponse();

            r.Code = (int)ServiceCodes.OK;
            r.Message = "Culturez-Vous webservice. Encryption : "+encrypt;

            return PrepareResponse(r, encrypt);
        }
        public ActionResult PrepareResponse(ServiceResponse response, bool encrypt = true)
        {
            string json = JsonHelper.Serialize(response);

            // Encryption
            if (encrypt)
            {
                return new ContentResult()
                {
                    Content = CVCrypto.Encrypt(json),
                    ContentType = "application/octet-stream"
                };
            }
            else
            {
                return new ContentResult()
                {
                    Content = json,
                    ContentType = "text/json"
                };
            }
        }