예제 #1
0
        public ActionResult New()
        {
            var results   = context.PointItems.ToList();
            var viewModel = new PointListViewModels
            {
                PointList  = new PointList(),
                PointItems = results
            };

            return(View(viewModel));
        }
예제 #2
0
        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"));
        }