public ActionResult SaveSubmissionPoint(SubmissionAndPointViewModel viewModel)
        {
            foreach (SubmissionPoint submissionPoint in viewModel.SubmissionPoints)
            {
                if (submissionPoint.Id == 0)
                {
                    _context.SubmissionPoint.Add(submissionPoint);
                }
                else
                {
                    var collectionPointDB = _context.SubmissionPoint.Single(c => c.Id == submissionPoint.Id);

                    collectionPointDB.Attribute         = submissionPoint.Attribute;
                    collectionPointDB.PointTypeId       = submissionPoint.PointTypeId;
                    collectionPointDB.Comments          = submissionPoint.Comments;
                    collectionPointDB.CollectionPointId = submissionPoint.CollectionPointId;
                }
            }

            _context.SaveChanges();

            TempData["message"] = "You successfully updated the Submission " + viewModel.Submission.Name + " with the suggested changes";
            //redirect to Collection
            return(RedirectToAction("Index", "Submission"));
        }
        public ActionResult Submission(int id, string newSubmissionList)
        {
            var submission = _context.Submission.Include(c => c.Collection).SingleOrDefault(c => c.Id == id);

            var submissionPoints = _context.SubmissionPoint.Where(sp => sp.SubmissionId == id).ToList();

            var collectionPoints = _context.CollectionPoint.Where(cp => cp.CollectionId == submission.CollectionId).ToList();

            var pointTypes = _context.PointType.ToList();

            if (newSubmissionList != null)
            {
                submissionPoints.Clear();

                List <string> model = JsonConvert.DeserializeObject <List <string> >(newSubmissionList);

                foreach (var list in model)
                {
                    submissionPoints.Add(new SubmissionPoint {
                        Attribute = list, PointTypeId = collectionPoints[0].Id, Comments = "", SubmissionId = id
                    });
                }
            }

            if (submission == null)
            {
                return(HttpNotFound());
            }

            if (submissionPoints == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new SubmissionAndPointViewModel
            {
                Submission       = submission,
                SubmissionPoints = submissionPoints,
                CollectionPoints = collectionPoints,
                PointTypes       = pointTypes
            };

            return(View(viewModel));
        }