コード例 #1
0
        // GET: NewGuidancePlan
        public ActionResult GuidancePlan(int id)
        {
            using (IHoneyMustardDataSource ds = HoneyMustard.Factories.DataSourceFactory.GetDataSource())
            {
                GuidancePlan gp = ds.GuidancePlan.Create();
                gp.StudentID       = id;
                gp.DateCreated     = DateTime.Now;
                gp.IsSaved         = false;
                gp.AuthorID        = 1; //This is No Author in database. Number needs to change depending on ContctID for this name.
                gp.DegreeID        = 1; //This is None in database. Number needs to change depending on DegreeID for this name.
                gp.PeriodStartYear = 2000;
                gp.PeriodEndYear   = 2000;
                ds.GuidancePlan.Add(gp);
                ds.SaveChanges();

                NewGuidancePlanHeadModels model = new NewGuidancePlanHeadModels
                {
                    TeudatZehutPassport = gp.Student.TeudatZehutPassport,
                    StudentName         = gp.Student.LastName + ", " + gp.Student.FirstMidName,
                    DateCreated         = gp.DateCreated,
                    GuidancePlanID      = gp.GuidancePlanID
                };

                return(View(model));
            }
        }
コード例 #2
0
        public ActionResult GuidancePlan(NewGuidancePlanHeadPostModel model)
        {
            using (IHoneyMustardDataSource ds = HoneyMustard.Factories.DataSourceFactory.GetDataSource())
            {
                if (ModelState.IsValid)
                {
                    GuidancePlan gp = ds.GuidancePlan.SingleOrDefault(x => x.GuidancePlanID == model.GuidancePlanID);
                    gp.IsSaved         = true;
                    gp.AuthorID        = model.AuthorID;
                    gp.DegreeID        = model.DegreeID;
                    gp.PeriodStart     = model.PeriodFrom;
                    gp.PeriodStartYear = model.YearFrom;
                    gp.PeriodEnd       = model.PeriodEnd;
                    gp.PeriodEndYear   = model.YearEnd;
                    ds.GuidancePlan.Add(gp);
                    ds.SaveChanges();
                }
                else
                {
                    Response.Write("modelstate not valid");
                    Response.End();
                }

                return(RedirectToAction("GuidancePlan", "NewGuidancePlan"));
            }
        }