public ActionResult Add(int?id)
        {
            DigitalResourceMasterModel model = new DigitalResourceMasterModel();

            if (id != null)
            {
                model = dmapping.ToObj(unitOfWork.DigitalResourceMasterRepository.GetByID(id));
                foreach (var item in model.DigitalResourceClasses)
                {
                    int clasid = (int)item.ClassId;
                    model.Selecteditems.Add(clasid);
                }
            }
            var clas = mapping.ToList(unitOfWork.LessonPlanClassRepository.Get().ToList());

            model.LessonPlanClassModellist = clas;
            return(View(model));
        }
        // GET: WeeklyPlan
        public ActionResult Index(int Id)
        {
            Session[WebUtil.File] = null;
            /*List<SelectListItem>*/
            var Subjects = unitOfWork.LessonPlanSubjectRepository.Get().Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            List <SelectListItem> Classes = unitOfWork.LessonPlanClassRepository.Get().Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            List <SelectListItem> categories = unitOfWork.LessonPlanCategoryRepository.Get(x => x.ParentId == Id).Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();

            ViewBag.subjects = Subjects;
            ViewBag.classes  = Classes;
            ViewBag.category = categories;
            LessonPlanModel model = new LessonPlanModel();

            return(View(model));
        }
        public ActionResult PostLessonPlan(LessonPlanModel model)
        {
            var detaillist = model.LessonPlanDetailList;
            var master     = model.LessonsPlanMasterModel;

            List <LessonsPlanMaster> masterlist = new List <LessonsPlanMaster>();
            List <FileSessionModel>  list       = ((List <FileSessionModel>)Session[WebUtil.File] == null) ? new List <FileSessionModel>() : (List <FileSessionModel>)Session[WebUtil.File];

            foreach (var i in detaillist)
            {
                foreach (var j in list)
                {
                    if (i.Id == Convert.ToInt32(j.categoryId))
                    {
                        if (j.date.Equals(i.Sunday))
                        {
                            //  LessonPlanDetail ede = new LessonPlanDetail();
                            LessonsPlanMaster masterobj = new LessonsPlanMaster();
                            masterobj.CategoryId         = Convert.ToInt32(j.categoryId);
                            masterobj.ClassId            = j.ClasId;
                            masterobj.SubjectId          = j.SubjectId;
                            masterobj.CreatedFor         = Convert.ToDateTime(j.date);
                            masterobj.AssignmentComments = i.SundayComment;
                            masterobj.CreatedOn          = DateTime.Now;
                            masterobj.CreatedBy          = "Naveed";
                            foreach (var k in j.FileList)
                            {
                                LessonPlanDetail ede = new LessonPlanDetail();
                                ede.FileExtnsion = k.extension;
                                ede.ShowFileName = k.FileName;
                                ede.URL          = k.URL;
                                ede.CreatedOn    = DateTime.Now;
                                ede.CreatedBy    = "Naveed";
                                masterobj.LessonPlanDetails.Add(ede);
                            }
                            masterlist.Add(masterobj);
                            unitOfWork.LessonsPlanMasterRepository.Insert(masterobj);
                            unitOfWork.Save();
                        }
                        if (j.date.Equals(i.Monday))
                        {
                            LessonsPlanMaster masterobj = new LessonsPlanMaster();
                            masterobj.CategoryId         = Convert.ToInt32(j.categoryId);
                            masterobj.ClassId            = j.ClasId;
                            masterobj.SubjectId          = j.SubjectId;
                            masterobj.CreatedFor         = Convert.ToDateTime(j.date);
                            masterobj.AssignmentComments = i.MondayComment;
                            masterobj.CreatedOn          = DateTime.Now;
                            masterobj.CreatedBy          = "Naveed";
                            foreach (var k in j.FileList)
                            {
                                LessonPlanDetail ede = new LessonPlanDetail();
                                ede.FileExtnsion = k.extension;
                                ede.ShowFileName = k.FileName;
                                ede.URL          = k.URL;
                                ede.CreatedOn    = DateTime.Now;
                                ede.CreatedBy    = "Naveed";
                                masterobj.LessonPlanDetails.Add(ede);
                            }
                            unitOfWork.LessonsPlanMasterRepository.Insert(masterobj);
                            unitOfWork.Save();
                        }
                        if (j.date.Equals(i.Tuesday))
                        {
                            LessonsPlanMaster masterobj = new LessonsPlanMaster();
                            masterobj.CategoryId         = Convert.ToInt32(j.categoryId);
                            masterobj.ClassId            = j.ClasId;
                            masterobj.SubjectId          = j.SubjectId;
                            masterobj.CreatedFor         = Convert.ToDateTime(j.date);
                            masterobj.AssignmentComments = i.TuesdayComent;
                            masterobj.CreatedOn          = DateTime.Now;
                            masterobj.CreatedBy          = "Naveed";
                            foreach (var k in j.FileList)
                            {
                                LessonPlanDetail ede = new LessonPlanDetail();
                                ede.FileExtnsion = k.extension;
                                ede.ShowFileName = k.FileName;
                                ede.URL          = k.URL;
                                ede.CreatedOn    = DateTime.Now;
                                ede.CreatedBy    = "Naveed";
                                masterobj.LessonPlanDetails.Add(ede);
                            }
                            masterlist.Add(masterobj);
                            unitOfWork.LessonsPlanMasterRepository.Insert(masterobj);
                            unitOfWork.Save();
                        }
                        if (j.date.Equals(i.Wednesday))
                        {
                            LessonsPlanMaster masterobj = new LessonsPlanMaster();
                            masterobj.CategoryId         = Convert.ToInt32(j.categoryId);
                            masterobj.ClassId            = j.ClasId;
                            masterobj.SubjectId          = j.SubjectId;
                            masterobj.CreatedFor         = Convert.ToDateTime(j.date);
                            masterobj.AssignmentComments = i.WednesdayComment;
                            masterobj.CreatedOn          = DateTime.Now;
                            masterobj.CreatedBy          = "Naveed";
                            foreach (var k in j.FileList)
                            {
                                LessonPlanDetail ede = new LessonPlanDetail();
                                ede.FileExtnsion = k.extension;
                                ede.ShowFileName = k.FileName;
                                ede.URL          = k.URL;
                                ede.CreatedOn    = DateTime.Now;
                                ede.CreatedBy    = "Naveed";
                                masterobj.LessonPlanDetails.Add(ede);
                            }
                            masterlist.Add(masterobj);
                            unitOfWork.LessonsPlanMasterRepository.Insert(masterobj);
                            unitOfWork.Save();
                        }
                        if (j.date.Equals(i.Thursday))
                        {
                            LessonsPlanMaster masterobj = new LessonsPlanMaster();
                            masterobj.CategoryId         = Convert.ToInt32(j.categoryId);
                            masterobj.ClassId            = j.ClasId;
                            masterobj.SubjectId          = j.SubjectId;
                            masterobj.CreatedFor         = Convert.ToDateTime(j.date);
                            masterobj.AssignmentComments = i.ThursdayComment;
                            masterobj.CreatedOn          = DateTime.Now;
                            masterobj.CreatedBy          = "Naveed";
                            foreach (var k in j.FileList)
                            {
                                LessonPlanDetail ede = new LessonPlanDetail();
                                ede.FileExtnsion = k.extension;
                                ede.ShowFileName = k.FileName;
                                ede.URL          = k.URL;
                                ede.CreatedOn    = DateTime.Now;
                                ede.CreatedBy    = "Naveed";
                                masterobj.LessonPlanDetails.Add(ede);
                            }
                            masterlist.Add(masterobj);
                            unitOfWork.LessonsPlanMasterRepository.Insert(masterobj);
                            unitOfWork.Save();
                        }
                    }
                }
            }

            return(RedirectToAction("Index"));
        }