コード例 #1
0
        public ActionResult AddEditPageMapping(FormCollection form, int param1 = 0)
        {
            var dal = GetDAL <StepCinemaDataLayer.DataAccess.StudiesLayer>();
            StudyPageMappingModel studyPageMappingModel = new StudyPageMappingModel();
            string studyNumber = form["StudyNumber"];
            int    periodValue = Convert.ToInt32(form["PeriodId"]);
            var    pagesValue  = form.GetValue("chkPages");

            studyPageMappingModel.StudyId = Convert.ToInt32(form["StudyId"]);
            if (pagesValue != null)
            {
                string[] pages = pagesValue.AttemptedValue.ToString().Split(',');
                foreach (string page in pages)
                {
                    studyPageMappingModel.FormGroupId.Add(page);
                }
            }

            studyPageMappingModel.PeriodId = periodValue;

            //studyPageMappingModel.FormGroupId.Add()
            if (ModelState.IsValid)
            {
                dal.UpdateFormGroupPeriods(studyPageMappingModel);
            }

            var model = dal.GetEditPageMappingData(studyNumber, periodValue);

            model.studyPageMapping.PeriodId = 2;
            return(View(model));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="studyPageMappingModel"></param>
        /// <returns></returns>
        public StudyPageMappingModel UpdateFormGroupPeriods(StudyPageMappingModel studyPageMappingModel)
        {
            List <StepCinemaDataLayer.EntityModel.FormGroupPeriod> data;
            var formGropPeriodActive = studyPageMappingModel.FormGroupId.ToList();

            ///formGropPeriod update Active data as false
            data = Entities.FormGroupPeriods
                   .Where(x => !formGropPeriodActive.Contains(x.FormGroupId))
                   .Where(x => x.StudyId == studyPageMappingModel.StudyId && x.PeriodId == studyPageMappingModel.PeriodId)
                   .ToList();
            data.ForEach(x => x.Active = false);
            Entities.SaveChanges();
            ///formGropPeriod update Active data as true
            data = Entities.FormGroupPeriods
                   .Where(x => formGropPeriodActive.Contains(x.FormGroupId))
                   .Where(x => x.StudyId == studyPageMappingModel.StudyId && x.PeriodId == studyPageMappingModel.PeriodId)
                   .ToList();
            data.ForEach(x => x.Active = true);
            Entities.SaveChanges();
            return(null);
        }