Пример #1
0
        public ActionResult PromoteToNewClass(StudentVM studentView, string Command)
        {
            int               StandardSectionId = 0;
            int               currentSerial     = 0;
            int               Serial            = 0;
            StudentVM         studView          = null;
            List <StudentDTO> studListPass      = null;

            if (Command != null)
            {
                // storing all data in studPass object and Passing it to PromoteToNewClass()
                studListPass = new List <StudentDTO>();

                if (string.Equals(Command, "Promotion Confirmed"))
                {
                    StatusDTO <List <StudentDTO> > batchStatus = _studSvc.PromoteToNewClass(null, Command, 0);

                    if (batchStatus.ReturnObj != null)
                    {
                        return(RedirectToAction("PromoteToNewClass"));
                    }
                }

                // To store StandardSectionId for Promote and Standard
                if (string.Equals(Command, "Promote"))
                {
                    StandardSectionId = (int)TempData.Peek("StandardSection");
                    //currentStandardId = StandardSectionId;
                }
                else if (string.Equals(Command, "Standard"))
                {
                    StandardSectionId           = studentView.StandardSectionMap.StandardSectionId;
                    TempData["StandardSection"] = StandardSectionId;
                }


                //For Storing exact string values instead of keys in database
                if (studentView != null && (string.Equals(Command, "Promote")))
                {
                    foreach (StudentVM studVM in studentView.studentList)
                    {
                        StudentDTO student = new StudentDTO();
                        student.StudentInfoId = studVM.StudentInfoId;

                        if (string.Equals(studVM.Status, "1"))
                        {
                            student.Status = "Promotion Confirmed";
                            student.NewStandardSectionId = studVM.NewStandardSectionId;
                        }
                        else if (string.Equals(studVM.Status, "2"))
                        {
                            student.Status = "Failed";
                            student.NewStandardSectionId = StandardSectionId;
                        }

                        studListPass.Add(student);
                    }
                }

                //Get Students for that Particular class or Promote Students to New Class
                StatusDTO <List <StudentDTO> > status = _studSvc.PromoteToNewClass(studListPass, Command, StandardSectionId);

                if ((status.ReturnObj != null))
                {
                    studView             = new StudentVM();        // Instantiating Student View model As a Parent Whole
                    studView.studentList = new List <StudentVM>(); // instantiating list of Students

                    //Binding the Standard Section Id which is returned from the database
                    studView.StandardSectionMap = new StandardSectionMapDTO();
                    studView.StandardSectionMap.StandardSectionId = StandardSectionId;

                    //Fetch the StandardSection List for Upper Dropdown
                    studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();

                    //Fetch the Promotion Status List
                    if (string.Equals(Command, "Standard"))
                    {
                        studView.PromotionStatusList = _uiddlRepo.getPromotionStatusDropDown();
                    }

                    if (status.IsSuccess && !status.IsException)
                    {
                        StudentVM studentV = null; // for each student
                        foreach (StudentDTO stud in status.ReturnObj)
                        {
                            if (stud != null)
                            {
                                studentV = new StudentVM(); // instantiating each student

                                studentV.Active        = stud.Active;
                                studentV.RollNumber    = stud.RollNumber;
                                studentV.StudentInfoId = stud.StudentInfoId;

                                studentV.Status = stud.Status;
                                studentV.NewStandardSectionId = stud.NewStandardSectionId;


                                //Fetch the Next StandardSectionList w.r.t Current
                                if (string.Equals(Command, "Standard"))
                                {
                                    currentSerial = stud.StandardSectionMap.Serial;
                                }

                                //Fetch New Standard and Section if they are assigned
                                studentV.StandardSectionMap          = new StandardSectionMapDTO();
                                studentV.StandardSectionMap.Standard = new StandardDTO();
                                studentV.StandardSectionMap.Section  = new SectionDTO();

                                studentV.StandardSectionMap.Standard.StandardName = stud.StandardSectionMap.Standard.StandardName;
                                studentV.StandardSectionMap.Section.SectionName   = studentV.StandardSectionMap.Section.SectionName;

                                studentV.NewStandardSectionMap = stud.NewStandardSectionMap;


                                studentV.UserDetails = new UserMasterDTO();
                                studentV.UserDetails.UserMasterId = stud.UserDetails.UserMasterId;
                                studentV.UserDetails.FName        = stud.UserDetails.FName;
                                studentV.UserDetails.MName        = stud.UserDetails.MName;
                                studentV.UserDetails.LName        = stud.UserDetails.LName;

                                studentV.Name = studentV.UserDetails.FName;
                                if (!string.IsNullOrEmpty(studentV.UserDetails.MName))
                                {
                                    studentV.Name = studentV.Name + " " + studentV.UserDetails.MName;
                                }

                                studentV.Name = studentV.Name + " " + studentV.UserDetails.LName;

                                //Add Into Student View Model List
                                studView.studentList.Add(studentV);
                                studView.IsSearchSuccessful = true;

                                if (!string.IsNullOrEmpty(studentV.Status))
                                {
                                    studView.IsCommandPromote = true;
                                }
                            }
                        }
                    }
                }
            }
            if (string.Equals(Command, "Standard"))
            {
                studView.NextStandardSectionList = _uiddlRepo.getNextStandardSectionDropDown(currentSerial);
            }
            return(View(studView));
        }