// GET: AomObjects/Create/AomMetaId public ActionResult Create(Guid id) { AomObject viewModel = new AomObject(); viewModel.AomMeta = db.AomMetas.FirstOrDefault(c => c.Id == id); // used to display the type viewModel.AomMetaId = viewModel.AomMeta.Id; viewModel.AomFieldObjects = viewModel.AomMeta.AomFieldMetas.Select(c => new AomFieldObject { AomFieldMetaId = c.Id, AomFieldMeta = c }).ToList(); // now make all the drop donw lists foreach (var aomFieldMeta in viewModel.AomMeta.AomFieldMetas) { if (aomFieldMeta.Name.Contains("Id")) { // Get a list of object that match the var testMe = db.RelationshipMetas.FirstOrDefault(cc => cc.FkAomFieldMetaId == aomFieldMeta.Id); if (testMe != null) { var dropDownObjects = db.AomObjects.Where(c => c.AomMetaId == testMe.PkAomMetaId).ToList(); ViewData[aomFieldMeta.Name] = dropDownObjects; } } } return(View(viewModel)); }
public ActionResult DeleteConfirmed(Guid id) { AomObject aomObject = db.AomObjects.Find(id); db.AomObjects.Remove(aomObject); db.SaveChanges(); return(RedirectToAction("Index")); }
public static AomObjectViewModel MapDbModelToViewModel(AomObject dbModel) { var viewModel = new AomObjectViewModel(); viewModel.ID = dbModel.ID; viewModel.AomMetaId = dbModel.AomMetaId; viewModel.Name = dbModel.Name; return(viewModel); }
public ActionResult Edit(AomObject aomObject) { if (ModelState.IsValid) { db.Entry(aomObject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aomObject)); }
public static AomObject MapInsertModelToDbModel(AomObjectViewModel model, AomObject newDomainModel = null) { if (newDomainModel == null) { newDomainModel = new AomObject(); } newDomainModel.ID = model.ID; newDomainModel.AomMetaId = model.AomMetaId; newDomainModel.Name = model.Name; return(newDomainModel); }
public ActionResult Create(AomObject aomObject) { aomObject.Id = Guid.NewGuid(); if (ModelState.IsValid) { db.AomObjects.Add(aomObject); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aomObject)); }
// GET: AomObjects/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AomObject aomObject = db.AomObjects.Find(id); if (aomObject == null) { return(HttpNotFound()); } return(View(aomObject)); }
// GET: AomObjects/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AomObject aomObject = db.AomObjects.Find(id); if (aomObject == null) { return(HttpNotFound()); } // fill up the ViewData with the Id and Display Name for the linkable objects if any var otherKeys = db.RelationshipMetas.Where(c => c.FkAomMetaId == aomObject.AomMetaId); return(View(aomObject)); }