public IActionResult Details(int?id) { AsignVM asignVM = new AsignVM() { Asign = new Asign(), TypeDropDown = _db.Employees.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }) }; if (id == null || id == 0) { return(NotFound()); } asignVM.Asign = _db.Asigns.Find(id); if (asignVM.Asign == null) { return(NotFound()); } return(View(asignVM)); }
public IActionResult Create(AsignVM obj) { if (ModelState.IsValid) { _db.Asigns.Add(obj.Asign); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(obj)); }
public IActionResult Create() { //IEnumerable<SelectListItem> typeDropDown = _db.Employees.Select(i => new SelectListItem //{ // Text =i.Name + " Speciality = " + i.Speciality, // Value = i.Id.ToString() //}); //ViewBag.typeDropDown = typeDropDown; AsignVM asignVM = new AsignVM() { Asign = new Asign(), TypeDropDown = _db.Employees.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }) }; return(View(asignVM)); }
public IActionResult UpdatePost(AsignVM obj) { _db.Asigns.Update(obj.Asign); _db.SaveChanges(); return(RedirectToAction("Index")); }