public ActionResult New() { var results = context.PointItems.ToList(); var viewModel = new PointListViewModels { PointList = new PointList(), PointItems = results }; return(View(viewModel)); }
public ActionResult Insert(PointListViewModels model) { string userId = User.Identity.GetUserId(); string userName = User.Identity.GetUserName(); var result = context.PointItems.FirstOrDefault(c => c.Id == model.PointList.PointItemId); var value = new PointList { UserId = userId, UserName = userName, PointItemId = model.PointList.PointItemId, PointItemName = result.Name, Points = model.PointList.Points, Remark = model.PointList.Remark, DateAdded = DateTime.Now }; context.PointLists.Add(value); context.SaveChanges(); return(RedirectToAction("Index", "PointList")); }