// GET: /<controller>/ public IActionResult Index() { var items = _context.GetAll() .Select(a => new InterpretationItemViewModel { Id = a.Id, Title = a.Title, Description = a.Description, ScoreFrom = a.ScoreFrom, ScoreTo = a.ScoreTo, }).ToList(); var model = new InterpretationIndexViewModel { Interpretations = items }; return(View(model)); }
public IActionResult Save(InterpretationIndexViewModel model) { var User = HttpContext.Session.GetString("UserId"); if (ModelState.IsValid) { var item = new Interpretation { Id = model.Interpretation.Id, Title = model.Interpretation.Title, Description = model.Interpretation.Description, ScoreFrom = model.Interpretation.ScoreFrom, ScoreTo = model.Interpretation.ScoreTo, CreatedBy = User, ModifiedBy = User }; _context.Save(item); } return(RedirectToAction("Index")); }