Пример #1
0
        public ActionResult Create(string[][] submission)
        {
            if (ModelState.IsValid)
            {
                Submission sub = new Submission();
                sub.SubmissionDate = DateTime.Now;

                db.Submissions.Add(sub);
                db.SaveChanges();

                for (int i = 0; i < submission.Length; i++)
                {
                    SubmissionDetail detail = new SubmissionDetail();
                    detail.SubmissionId = sub.Id;
                    detail.CriteriaId = int.Parse(submission[i][0]);
                    detail.SelectedItemId = int.Parse(submission[i][1]);

                    db.SubmissionDetails.Add(detail);
                }

                db.SaveChanges();

                return RedirectToAction("Index");
            }

            return View();
        }
Пример #2
0
        public ActionResult Create(SubmissionDetail submissiondetail)
        {
            if (ModelState.IsValid)
            {
                db.SubmissionDetails.Add(submissiondetail);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.SubmissionId = new SelectList(db.Submissions, "Id", "Id", submissiondetail.SubmissionId);
            ViewBag.CriteriaId = new SelectList(db.Criterias, "Id", "Name", submissiondetail.CriteriaId);
            ViewBag.SelectedItemId = new SelectList(db.CriteriaItems, "Id", "Name", submissiondetail.SelectedItemId);
            return View(submissiondetail);
        }