コード例 #1
0
        public ActionResult Edit(int id)
        {
            Student2Repository     objStudent2Repository     = new Student2Repository();
            Student2ViewModel      objEntity                 = new Student2ViewModel();
            CountryStateRepository objCountryStateRepository = new CountryStateRepository();

            objEntity = objStudent2Repository.Select(StudentFlags.SelectByID.GetHashCode(), new Student2ViewModel()
            {
                StudentId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                return(RedirectToAction("Index"));
            }
            objEntity.CurrentTimeValue = objEntity.CurrentTime.HasValue ? objEntity.CurrentTime.Value.ToString("hh:mm tt") : string.Empty;


            #region DatabaseDropdown
            var objCourseRepository      = new CourseRepository();
            var objCourseViewModelEntity = objCourseRepository.Select(CourseFlags.SelectAll.GetHashCode(), new CourseViewModel());
            objEntity.CourseList = new SelectList(objCourseViewModelEntity.Select(model => new { model.CourseId, model.CourseTitle }), "CourseId", "CourseTitle");
            #endregion

            #region DatabaseOptionGroup


            var objCountryStateEntityList = objCountryStateRepository.Select(CountryStateFlags.SelectAllForOptionGroup.GetHashCode(), new CountryStateViewModel());
            objEntity.SelectCountryList = new SelectList(objCountryStateEntityList, "StateId", "StateName", "CountryName", 1);
            #endregion
            return(View(objEntity));
        }
コード例 #2
0
        // GET: Student3
        public ActionResult Search(string Keyword)
        {
            if (!string.IsNullOrWhiteSpace(Keyword) || !string.IsNullOrEmpty(Keyword))
            {
                Keyword = Keyword.Trim();
            }
            var objEntity = new Student2ViewModel()
            {
                Keyword = Keyword
            };


            var objStudent2Repository = new Student2Repository();

            // objEntity.Student2SearchList = new List<Student2ViewModel>();

            objEntity.Student2SearchList = objStudent2Repository.Search(StudentFlags.SelectAllByKeyword.GetHashCode(), objEntity);



            if (objEntity.Student2SearchList.Count >= 0 && !string.IsNullOrWhiteSpace(Keyword))
            {
                this.Flash("Success", string.Format("Your search for '{0}' returns {1} result(s).", Keyword, objEntity.Student2SearchList.Count().ToString()));
            }
            else if (objEntity.Student2SearchList.Count == 0)
            {
                this.Flash("Warning", string.Format(@"Your search returns {0} result(s)", 0));
                //flash message
            }

            return(View(objEntity));
        }
コード例 #3
0
        public ActionResult Dashboard()
        {
            var objEntity             = new UserDashboardViewModel();
            var objStudent2Repository = new Student2Repository();


            #region RecentMembersDashboard

            objEntity.Student2RecentMembersList = objStudent2Repository.Select(StudentFlags.SelectAllByRecentMembers.GetHashCode(), new Student2ViewModel()
            {
                CreatedBy = 1 //Admin UserId or login UserId
            });

            #endregion
            #region RecentActiveMembersDashboard

            objEntity.Student2RecentActiveMembersList = objStudent2Repository.Select(StudentFlags.SelectAllByRecentActiveMembers.GetHashCode(), new Student2ViewModel()
            {
                CreatedBy = 1 //Admin UserId or login UserId
            });

            #endregion



            if (objEntity.Student2RecentMembersList.Count == 0)
            {
                // this.Flash("Warning", string.Format(@"Your search returns {0} result(s)", 0));
                //flash message
            }

            return(View(objEntity));
        }
コード例 #4
0
        public ActionResult Report(string strFromDate, string strToDate, int filterId = 0)
        {
            Student2ViewModel objEntity = new Student2ViewModel();
            var objStudent2Repository   = new Student2Repository();

            objEntity.Student2ReportList = new List <Student2ViewModel>();

            if (string.IsNullOrEmpty(strFromDate))
            {
                objEntity.FromDate = null;
            }
            else
            {
                objEntity.strFromDate = strFromDate;
                objEntity.FromDate    = Convert.ToDateTime(strFromDate);
            }
            if (string.IsNullOrEmpty(strToDate))
            {
                objEntity.ToDate = null;
            }
            else
            {
                objEntity.strToDate = strToDate;
                objEntity.ToDate    = Convert.ToDateTime(strToDate);
            }

            objEntity.CourseId = filterId;
            objEntity.filterId = filterId;

            #region DatabaseDropdown

            var objCourseRepository      = new CourseRepository();
            var objCourseViewModelEntity = objCourseRepository.Select(CourseFlags.SelectAll.GetHashCode(), new CourseViewModel());
            objEntity.CourseList = new SelectList(objCourseViewModelEntity.Select(model => new { model.CourseId, model.CourseTitle }), "CourseId", "CourseTitle");

            #endregion

            if (objEntity.FromDate.HasValue && objEntity.ToDate.HasValue && objEntity.FromDate > objEntity.ToDate)
            {
                this.Flash("Warning", "From Date is smaller than To Date.");
                return(View(objEntity));
            }



            objEntity.Student2ReportList = objStudent2Repository.Report(StudentFlags.SelectAllByReport.GetHashCode(), objEntity);


            if (objEntity.Student2ReportList.Count == 0 && (!string.IsNullOrEmpty(strFromDate) || !string.IsNullOrEmpty(strToDate) || filterId > 0))
            {
                this.Flash("Warning", "No matching records found.");
            }


            return(View(objEntity));
        }
コード例 #5
0
        public ActionResult Index()
        {
            var objStudent2Repository = new Student2Repository();
            List <Student2ViewModel> objEntityList = objStudent2Repository.Select(StudentFlags.SelectAll.GetHashCode(), new Student2ViewModel());

            if (objEntityList.Count == 0)
            {
                this.Flash("Error", "No Students");
            }
            return(View(objEntityList));
        }
コード例 #6
0
        public ActionResult ListGalleryTop4Random()
        {
            var objStudent2Repository = new Student2Repository();
            List <Student2ViewModel> objEntityList = objStudent2Repository.Select(StudentFlags.SelectTop4ByRandom.GetHashCode(), new Student2ViewModel());

            if (objEntityList.Count == 0)
            {
                this.Flash("Error", "No Students");
            }


            return(PartialView("_PartialListGalleryTop4Random", objEntityList));
        }
コード例 #7
0
        public ActionResult Details(int id)
        {
            Student2Repository objStudent2Repository = new Student2Repository();
            Student2ViewModel  objEntity             = new Student2ViewModel();

            objEntity = objStudent2Repository.Select(StudentFlags.SelectByID.GetHashCode(), new Student2ViewModel()
            {
                StudentId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(objEntity));
        }
コード例 #8
0
        public ActionResult Delete(int id)
        {
            int result = 0;
            Student2Repository objStudent2Repository = new Student2Repository();

            Student2ViewModel      objEntity = new Student2ViewModel();
            CountryStateRepository objCountryStateRepository = new CountryStateRepository();

            objEntity = objStudent2Repository.Select(StudentFlags.SelectByID.GetHashCode(), new Student2ViewModel()
            {
                StudentId = id
            }).FirstOrDefault();
            if (objEntity == null)
            {
                //delete old file

                ApplicationHelpers.DeleteFile(Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_STUDENT_IMAGE_PATH), objEntity.FileName));
            }


            result = objStudent2Repository.Delete(StudentFlags.DeleteByID.GetHashCode(), new Student2ViewModel()
            {
                StudentId = id,
            });
            if (result == ResultFlags.Success.GetHashCode())
            {
                this.Flash("success", "Student Delete successfully");
                return(RedirectToAction("Index"));
            }
            else if (result == ResultFlags.Failure.GetHashCode())
            {
                this.Flash("error", "Faild to Delete Student");
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public ActionResult Create(Student2ViewModel objEntity)
        {
            Student2Repository     objStudent2Repository     = new Student2Repository();
            CountryStateRepository objCountryStateRepository = new CountryStateRepository();
            string fileName = string.Empty;

            if (ModelState.IsValid)
            {
                objEntity.Status = StatusEnum.Active;

                objEntity.CreatedBy = 1;//admin userid



                #region FileUpload

                if (objEntity.UploadFile != null)
                {
                    fileName           = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UploadFile.FileName);
                    objEntity.FileName = fileName;
                }
                else
                {
                    objEntity.FileName = string.Empty;
                }



                #endregion
                objEntity = objStudent2Repository.Insert(objEntity);

                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    #region FileUpload

                    //file name
                    if (objEntity.UploadFile != null)
                    {
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_STUDENT_IMAGE_PATH), fileName);
                        // WebImage.Save()
                        objEntity.UploadFile.SaveAs(path);
                    }



                    #endregion
                    //   Install-Package MvcFlashMessages
                    this.Flash("Success", "Student Insert successfully ");

                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("Error", "Faild to Insert Student");
                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("Warning", "Student Name is Already Exist");
                    return(RedirectToAction("Index"));
                }
            }
            #region DatabaseDropdown
            var objCourseRepository      = new CourseRepository();
            var objCourseViewModelEntity = objCourseRepository.Select(CourseFlags.SelectAll.GetHashCode(), new CourseViewModel());
            objEntity.CourseList = new SelectList(objCourseViewModelEntity.Select(model => new { model.CourseId, model.CourseTitle }), "CourseId", "CourseTitle");
            #endregion

            #region DatabaseOptionGroup


            var objCountryStateEntityList = objCountryStateRepository.Select(CountryStateFlags.SelectAllForOptionGroup.GetHashCode(), new CountryStateViewModel());
            objEntity.SelectCountryList = new SelectList(objCountryStateEntityList, "StateId", "StateName", "CountryName", 1);
            #endregion
            return(View(objEntity));
        }
コード例 #10
0
        public ActionResult Edit(int id, Student2ViewModel objEntity)
        {
            Student2Repository     objStudent2Repository     = new Student2Repository();
            CountryStateRepository objCountryStateRepository = new CountryStateRepository();
            string fileName    = string.Empty;
            string oldFileName = string.Empty;

            if (ModelState.IsValid)
            {
                objEntity.Name      = objEntity.Name.Trim();
                objEntity.StudentId = id;
                oldFileName         = objEntity.FileName;

                #region FileUpload

                if (objEntity.UploadFile != null)
                {
                    fileName           = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UploadFile.FileName);
                    objEntity.FileName = fileName;
                }


                #endregion



                objEntity = objStudent2Repository.Update(StudentFlags.UpdateByID.GetHashCode(), objEntity);
                if (objEntity.Result == ResultFlags.Success.GetHashCode())
                {
                    #region FileUpload
                    //delete old file



                    //file name
                    if (objEntity.UploadFile != null)
                    {
                        if (!string.IsNullOrEmpty(objEntity.UploadFile.FileName))
                        {
                            ApplicationHelpers.DeleteFile(Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_STUDENT_IMAGE_PATH), oldFileName));
                        }
                        string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_STUDENT_IMAGE_PATH), fileName);
                        // WebImage.Save()
                        objEntity.UploadFile.SaveAs(path);
                    }



                    #endregion
                    this.Flash("success", "Student Details updated successfully");
                    return(RedirectToAction("Index"));
                }
                else if (objEntity.Result == ResultFlags.Failure.GetHashCode())
                {
                    this.Flash("error", "Student Details failed to Update");
                }
                else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode())
                {
                    this.Flash("warning", "Student Name is Already Exist");
                }
            }
            #region DatabaseDropdown
            var objCourseRepository      = new CourseRepository();
            var objCourseViewModelEntity = objCourseRepository.Select(CourseFlags.SelectAll.GetHashCode(), new CourseViewModel());
            objEntity.CourseList = new SelectList(objCourseViewModelEntity.Select(model => new { model.CourseId, model.CourseTitle }), "CourseId", "CourseTitle");
            #endregion

            #region DatabaseOptionGroup


            var objCountryStateEntityList = objCountryStateRepository.Select(CountryStateFlags.SelectAllForOptionGroup.GetHashCode(), new CountryStateViewModel());
            objEntity.SelectCountryList = new SelectList(objCountryStateEntityList, "StateId", "StateName", "CountryName", 1);
            #endregion


            return(View(objEntity));
        }