public IActionResult Index() { var result = _Services.Positions().Select (a => new PositionViewModel { Id = a.Id, Description = a.Description, Level = a.PositionLevel.Id, LevelDescription = a.PositionLevel.Description, }).ToList(); var levels = _Services.PositionLevels() .Select(a => new PositionLevelItem { Id = a.Id, Description = a.Description, Level = a.Level }).ToList(); var model = new PositionIndexViewModel { Positions = result, Levels = levels, }; return(View(model)); }
public IActionResult Index() { var result = _Position.Positions().Select (a => new PositionViewModel { Id = a.Id, Description = a.Description }).ToList(); var model = new PositionIndexViewModel { Positions = result }; return(View(model)); }
public IActionResult Save(PositionIndexViewModel model) { var UserId = int.Parse(HttpContext.Session.GetString("UserId")); if (ModelState.IsValid) { var item = new Position { Id = model.Id, Description = model.Description, PositionLevel = _Services.PositionLevelById(model.Level), }; _Services.Save(item, UserId); } return(RedirectToAction("Index")); }