Esempio n. 1
0
        public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo)
        {
            LensProtectionRepository repository = new LensProtectionRepository();
            List <LensProtection>    lensProtectionList;
            LensProtection           lensProtection;

            string[] str = requestInfo.Body.Split('/');
            switch (str[0])
            {
            case "Get":
                lensProtectionList = repository.GetList();
                string message = JsonConvert.SerializeObject(lensProtectionList);
                session.Send(message);
                break;

            case "Set":
                lensProtection = JsonConvert.DeserializeObject <LensProtection>(str[1]);
                try
                {
                    repository.Update(lensProtection);
                    session.Send(true.ToString());
                }
                catch { session.Send(false.ToString()); }
                break;
            }
        }