Пример #1
0
        public void UpdateModel(CtrlBaseModel newModel)
        {
            var index      = 0;
            var modelsTemp = Models;

            newModel.EncodedModel = CtrlBaseModel.Base64Encode(newModel.ToString());
            newModel.UpdatedModel = true;

            foreach (var model in modelsTemp)
            {
                if (model.Id.Equals(newModel.Id))
                {
                    Models[index] = newModel;
                    return;
                }
                index++;
            }
        }
Пример #2
0
        public T GetCtrlModel <T>(string id)
        {
            var index = 0;

            var modelsTemp = Models;

            foreach (var model in Models)
            {
                if (model.Id.Equals(id))
                {
                    var jsonModel = CtrlBaseModel.Base64Decode(model.EncodedModel);

                    var serializer = new JavaScriptSerializer();
                    var ctrlModel  = serializer.Deserialize <T>(jsonModel);

                    return(ctrlModel);
                }

                index++;
            }

            return(default(T));
        }