Пример #1
0
        public ActionResult EditAttribute(int id, int pid, string optionType)
        {
            var attribute = new GeneratedAttribute();

            if (id > -1)
            {
                attribute = repo.GetGeneratedAttribute().FirstOrDefault(x => x.ID == id);
            }
            ViewBag.pid  = pid;
            ViewBag.aid  = id;
            ViewBag.type = optionType;
            var modelType = Type.GetType(optionType);
            I_GeneratedOption model;

            if (string.IsNullOrEmpty(attribute.Value))
            {
                model = ApiHelper.CreateInstance(modelType) as I_GeneratedOption;
            }
            else
            {
                model = JsonConvert.DeserializeObject(attribute.Value, modelType) as I_GeneratedOption;
            }
            return(View(model));
        }