示例#1
0
        public IActionResult Create(MetadataUIViewModel metadataUI)
        {
            if (ModelState.IsValid)
            {
                if (db.MetadataUI.Any(m => m.Id == metadataUI.Metadata.Id))
                {
                    db.MetadataUI.Update(metadataUI.Metadata);
                }
                else
                {
                    db.MetadataUI.Add(metadataUI.Metadata);
                }
                db.SaveChanges();
            }

            return Redirect($"/Admin/MetadataUI/?modelId={metadataUI.Metadata.ModelId}");
        }
示例#2
0
        public IActionResult Index(Guid? modelId, Guid? id)
        {
            if (modelId == null)
            {
                return new HttpStatusCodeResult(404);
            }

            var list = db.MetadataUI.Where(m => m.ModelId == modelId);
            if (list == null)
            {
                list = new List<MetadataUI>().AsQueryable();
            }

            var metadata = id == null ? new MetadataUI { ModelId = modelId.Value } :
                db.MetadataUI.SingleOrDefault(m => m.Id == id.Value);

            var vm = new MetadataUIViewModel
            {
                Metadata = metadata,
                MetadataList = list
            };

            return View(vm);
        }