public ActionResult AuxAdd() { var model = new Format(); return PartialView("_FormatFields", model); }
public async Task<ActionResult> AuxAdd(Format t) { var cl = db.Entities .FirstOrDefault(c => t.FormatDescription == c.FormatDescription); if (cl == null) { cl = t; db.Add(t); await db.SaveChangesAsync(); } return Json((await db.Entities .OrderBy(ct => ct.Id) .ToListAsync()) .Select(ct => new { value = ct.Id.ToString(), text = ct.FormatDescription, selected = ct.Id == cl.Id }) .ToList()); }
private bool DoesFormatExist(Format format) { return db.Entities .Any(f => f.Id != format.Id && f.FormatDescription == format.FormatDescription); }