public IActionResult Create(web_db.TblGroup model) { try { var x = db.TblGroups.Find(model.Id); if (x == null) { x = new web_db.TblGroup { Id = Guid.NewGuid() }; db.TblGroups.Add(x); } x.IsActive = model.IsActive; x.Title = model.Title; x.Fklocation = model.Fklocation; x.Class = model.Class; db.SaveChanges(); ViewBag.txt = "ثبت انجام شد"; Models.cl._ListGroup = db.TblGroups.OrderBy(a => a.Title).ToList(); return(RedirectToAction(nameof(Index))); } catch { ViewBag.error = "ثبت انجام نشد"; } return(View(model)); }
public IActionResult Create(Guid id) { var row = db.TblGroups.Find(id); if (row == null) { row = new web_db.TblGroup { IsActive = true }; } ViewBag.nums = string.Join(System.Environment.NewLine, db.TblCustomerGroups.Include(a => a.FkCustumerNavigation).Where(a => a.FkGroup == id).Select(a => a.FkCustumerNavigation.Mob)); return(View(row)); }