public LessonsPlanMasterModel ToObj(LessonsPlanMaster LessonsPlan) { if (LessonsPlan != null) { LessonsPlanMasterModel obj = new LessonsPlanMasterModel() { Id = LessonsPlan.Id, ApprovedBy = LessonsPlan.ApprovedBy, Class = LessonsPlan.LessonPlanClass.Name, CreatedBy = LessonsPlan.CreatedBy, CreatedOn = LessonsPlan.CreatedOn, HOSRemarks = LessonsPlan.HOSRemarks, IsActive = LessonsPlan.IsActive, IsApproved = LessonsPlan.IsApproved, LessonPlanFrom = LessonsPlan.LessonPlanFrom, LessonPlanTo = LessonsPlan.LessonPlanTo, ModefiedBy = LessonsPlan.ModefiedBy, ModefiedOn = LessonsPlan.ModefiedOn, Subject = LessonsPlan.LessonPlanSubject.Name, Category = LessonsPlan.LessonPlanCategory.Name, Datefor = Convert.ToDateTime(LessonsPlan.CreatedFor).ToShortDateString(), Day = Convert.ToString(Convert.ToDateTime(LessonsPlan.CreatedFor).DayOfWeek), Teacher = LessonsPlan.CreatedBy, TeacherRemarks = LessonsPlan.AssignmentComments, LessonPlanDetailList = ToList(LessonsPlan.LessonPlanDetails) }; return(obj); } return(null); }
public LessonsPlanMaster ToObj(LessonsPlanMaster master, LessonsPlanMasterModel LessonsPlan) { if (master != null) { master.Id = LessonsPlan.Id; master.ApprovedBy = LessonsPlan.ApprovedBy; master.Class = LessonsPlan.Class; master.CreatedBy = LessonsPlan.CreatedBy; master.CreatedOn = LessonsPlan.CreatedOn; master.HOSRemarks = LessonsPlan.HOSRemarks; master.IsActive = LessonsPlan.IsActive; master.IsApproved = LessonsPlan.IsApproved; master.LessonPlanFrom = LessonsPlan.LessonPlanFrom; master.LessonPlanTo = LessonsPlan.LessonPlanTo; master.ModefiedBy = LessonsPlan.ModefiedBy; master.ModefiedOn = LessonsPlan.ModefiedOn; master.Subject = LessonsPlan.Subject; return(master); } return(null); }
public ActionResult EditPost(LessonsPlanMasterModel model) { var data = unitOfWork.LessonsPlanMasterRepository.GetByID(model.Id); foreach (var item in model.LessonPlanDetailList) { var data2 = unitOfWork.LessonPlanDetailRepository.GetByID(item.Id); data2.IsActive = item.IsActive; unitOfWork.Save(); } data.HOSRemarks = model.HOSRemarks; data.IsApproved = model.IsApproved; data.AssignmentComments = model.HOSRemarks; foreach (string fcName in Request.Files) { LessonPlanDetail filedetail = new LessonPlanDetail(); HttpPostedFileBase file = Request.Files[fcName]; if (!string.IsNullOrEmpty(file.FileName)) { filedetail.ShowFileName = file.FileName; filedetail.FileExtnsion = file.FileName.Substring(file.FileName.LastIndexOf(".")); filedetail.URL = DateTime.Now.Ticks.ToString(); filedetail.Master_Id = data.Id; filedetail.CreatedBy = "Naveed"; filedetail.CreatedOn = DateTime.Now; string dynamicpath = data.LessonPlanCategory.Name + "/" + data.LessonPlanClass.Name + "_" + data.LessonPlanSubject.Name; string path = "/Images/LessonPlan/" + dynamicpath + "/" + filedetail.URL + filedetail.FileExtnsion; string createpath = "/Images/LessonPlan/" + dynamicpath; string dicrectory = Request.MapPath(createpath); Directory.CreateDirectory(dicrectory); string dicrectory2 = Request.MapPath(path); file.SaveAs(dicrectory2); data.LessonPlanDetails.Add(filedetail); } //string[] nameandextension = file.FileName.Split('.'); } unitOfWork.Save(); return(RedirectToAction("Index")); }
public bool AddUser(LessonsPlanMasterModel LessonsPlan) { try { if (LessonsPlan.Id > 0) { var get = UnitOfWork.LessonsPlanMasterRepository.GetByID(LessonsPlan.Id); UnitOfWork.LessonsPlanMasterRepository.Update(LessonPlanMapping.ToObj(get, LessonsPlan)); UnitOfWork.Save(); return(true); } else { UnitOfWork.LessonsPlanMasterRepository.Insert(LessonPlanMapping.ToObj(LessonsPlan)); UnitOfWork.Save(); return(true); } } catch (Exception ex) { return(false); } }
public LessonsPlanMaster ToObj(LessonsPlanMasterModel LessonsPlan) { if (LessonsPlan != null) { LessonsPlanMaster obj = new LessonsPlanMaster() { Id = LessonsPlan.Id, ApprovedBy = LessonsPlan.ApprovedBy, Class = LessonsPlan.Class, CreatedBy = LessonsPlan.CreatedBy, CreatedOn = LessonsPlan.CreatedOn, HOSRemarks = LessonsPlan.HOSRemarks, IsActive = LessonsPlan.IsActive, IsApproved = LessonsPlan.IsApproved, LessonPlanFrom = LessonsPlan.LessonPlanFrom, LessonPlanTo = LessonsPlan.LessonPlanTo, ModefiedBy = LessonsPlan.ModefiedBy, ModefiedOn = LessonsPlan.ModefiedOn, Subject = LessonsPlan.Subject }; return(obj); } return(null); }