Esempio n. 1
0
        private string cliente(HttpContext context)
        {
            option = context.Request["opt"].ToString();
            Cliente o = new Cliente();

            switch (option)
            {
            case "sltById":
                if (context.Request["key"] != null)
                {
                    int.TryParse(context.Request["key"], out id);
                }
                o.Id = id;
                CatalogoCtrl.catalogSelById(o);
                o.PLstCteReg = CatalogoCtrl.clienteRegLstByCte(o.Id);
                response     = JsonConvert.SerializeObject(o);
                break;

            case "add":
                jsonData = new StreamReader(context.Request.InputStream).ReadToEnd();
                o        = JsonConvert.DeserializeObject <Cliente>(jsonData);
                CatalogoCtrl.clienteAdd(o);
                response = JsonConvert.SerializeObject(o);
                break;

            case "udt":
                jsonData = new StreamReader(context.Request.InputStream).ReadToEnd();
                o        = JsonConvert.DeserializeObject <Cliente>(jsonData);
                CatalogoCtrl.clienteUdt(o);
                response = JsonConvert.SerializeObject(o);
                break;

            case "lst":
                response = JsonConvert.SerializeObject(CatalogoCtrl.catalogGetLst(o).Cast <Cliente>().ToList());
                break;

            case "lstAll":
                response = JsonConvert.SerializeObject(CatalogoCtrl.catalogGetAllLst(o).Cast <Cliente>().ToList());
                break;

            case "enb":
                if (context.Request["key"] != null)
                {
                    int.TryParse(context.Request["key"], out id);
                }
                o.Id = id;
                CatalogoCtrl.catalogEnabled(o);
                o.IsActive = true;
                response   = JsonConvert.SerializeObject(o);
                break;

            case "dsb":
                if (context.Request["key"] != null)
                {
                    int.TryParse(context.Request["key"], out id);
                }
                o.Id = id;
                CatalogoCtrl.catalogDisabled(o);
                o.IsActive = false;
                response   = JsonConvert.SerializeObject(o);
                break;

            default:
                break;
            }
            return(response);
        }