Exemple #1
0
        //[Route("Student/Details")]
        public ViewResult Details()
        {
            ViewBag.Title  = "Student Details Page";
            ViewBag.Header = "Student Details";
            //Student Basic Details
            Student student = new Student()
            {
                StudentId = 101,
                Name      = "Dillip",
                Branch    = "CSE",
                Section   = "A",
                Gender    = "Male"
            };
            //Student Address
            Address address = new Address()
            {
                StudentId = 101,
                City      = "Mumbai",
                State     = "Maharashtra",
                Country   = "India",
                Pin       = "400097"
            };
            //Creating the View model
            StudentDetailsViewModel studentDetailsViewModel = new StudentDetailsViewModel()
            {
                Student = student,
                Address = address,
                Title   = "Student Details Page",
                Header  = "Student Details",
            };

            //Pass the studentDetailsViewModel to the view
            return(View(studentDetailsViewModel));
        }
        public async Task <ActionResult> Edit(string id, StudentDetailsViewModel model)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (!ModelState.IsValid)
            {
                var viewModel = new StudentDetailsViewModel();
                return(View(viewModel));
            }

            var studentDb = await db.Students.SingleOrDefaultAsync(x => x.Id == id);

            var student = map.ModifyStudentObject(model, studentDb);

            try
            {
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Edit"));
            }
        }
Exemple #3
0
        public ActionResult Details(int id)
        {
            var studentInDb = _studentService.GetStudentById(id);

            if (studentInDb == null)
            {
                return(HttpNotFound());
            }

            var universityInDb    = _universityService.GetUniversityByStudentId(id);
            var facultyInDb       = _facultyService.GetFacultyByStudentId(id);
            var departmentInDb    = _departmentService.GetDepartmentByStudentId(id);
            var educationTypeInDb = _educationTypeService.GetEducationTypeByStudentId(id);
            var graduateTypeInDb  = _graduateTypeService.GetGraduateTypeByStudentId(id);

            var viewModel = new StudentDetailsViewModel
            {
                StudentDto       = Mapper.Map <Student, StudentDto>(studentInDb),
                UniversityDto    = Mapper.Map <University, UniversityDto>(universityInDb),
                FacultyDto       = Mapper.Map <Faculty, FacultyDto>(facultyInDb),
                DepartmentDto    = Mapper.Map <Department, DepartmentDto>(departmentInDb),
                EducationTypeDto = Mapper.Map <EducationType, EducationTypeDto>(educationTypeInDb),
                GraduateTypeDto  = Mapper.Map <GraduateType, GraduateTypeDto>(graduateTypeInDb)
            };

            return(View(viewModel));
        }
        public StudentDetailsViewModel GetStudentbyDetailsById(int Deptid, int StudentId)
        {
            string query = "SELECT StudentName,RegistrationNo,ContactNo,Email,Date,Address,Code,Name FROM Student INNER JOIN Departments ON Student.DepartmentId = @deptId WHERE StudentId = @studentId";

            //"SELECT StudentName,Email,Code FROM Student INNER JOIN Departments ON Student.DepartmentId=Departments.DeptId AND StudentId=@StudentId"
            Command = new SqlCommand(query, Connection);
            Command.Parameters.AddWithValue("@deptid", Deptid);
            Command.Parameters.AddWithValue("@studentId", StudentId);
            Connection.Open();
            Reader = Command.ExecuteReader();
            StudentDetailsViewModel aStudent = new StudentDetailsViewModel();

            if (Reader.HasRows)
            {
                aStudent.StudentName     = Reader["StudentName"].ToString();
                aStudent.StudentRegNo    = Reader["RegistrationNo"].ToString();
                aStudent.StudentEmail    = Reader["Email"].ToString();
                aStudent.StudentDate     = Reader["Date"].ToString();
                aStudent.StudentAddress  = Reader["Address"].ToString();
                aStudent.StudentDeptCode = Reader["Code"].ToString();
                aStudent.StudentDeptName = Reader["Name"].ToString();
            }

            Reader.Close();
            Connection.Close();
            return(aStudent);
        }
Exemple #5
0
        public async Task <IActionResult> StudentDetails(Guid id)
        {
            var asg = await _context.Assignments
                      .Include(a => a.Stages)
                      .Include(a => a.Course)
                      .ThenInclude(c => c.Affiliates)
                      .Include(a => a.Groups)
                      .ThenInclude(g => g.Members)
                      .ThenInclude(gjt => gjt.ApplicationUser)
                      .SingleOrDefaultAsync(a => a.ID == id);

            if (asg == null)
            {
                return(NotFound());
            }

            var user = await _userManager.GetUserAsync(User);

            if (!(asg.Course.RoleFor(user) == CourseJoinTag.ROLE_STUDENT))
            {
                return(NotFound());
            }

            if (asg.GroupSatisfied(user))
            {
                var group = asg.GroupFor(user);
                var subs  = _context.Submissions
                            .Include(s => s.AssignmentStage)
                            .ThenInclude(stage => stage.Assignment)
                            .Include(s => s.Submitter)
                            .Include(s => s.Files)
                            .OrderByDescending(s => s.AssignmentStage.Seq)
                            .Where(s =>
                                   (s.Submitter.Id == user.Id && s.AssignmentStage.Assignment.ID == asg.ID) ||
                                   (group != null && s.ForGroup.ID == group.ID));
                var xsubs = subs.Select(s => new ExtendedSubmission
                {
                    Submission = s,
                    Reviews    = _context.Reviews
                                 .Where(r => r.Submission.ID == s.ID)
                                 .OrderBy(r => r.TimeStamp)
                                 .ToList(),
                });
                var vm = new StudentDetailsViewModel
                {
                    Group      = group,
                    Assignment = asg,
                    // TODO: StageFprUser is disgusting
                    Stage       = (group == null) ? asg.StageForUser(user, _context) : group.NextStage(),
                    Submissions = await xsubs.ToListAsync(),
                };

                return(View(vm));
            }

            return(RedirectToAction(nameof(GroupSetup), new
            {
                forAssignment = id
            }));
        }
        public ActionResult Register(Student student)
        {
            student.RegistrationNo = GenerateRegNo(student);
            ViewBag.Message        = aStudentManager.Save(student);
            ViewBag.Departments    = aDepartmentManager.GetAllDepartments();

            string deptCode = aDepartmentManager.GetDepartmentbyId(student.DepartmentId).Code;
            string deptName = aDepartmentManager.GetDepartmentbyId(student.DepartmentId).Name;
            StudentDetailsViewModel studentDetails = new StudentDetailsViewModel();

            studentDetails.StudentName     = student.StudentName;
            studentDetails.StudentEmail    = student.Email;
            studentDetails.StudentRegNo    = student.RegistrationNo;
            studentDetails.StudntContactNo = student.ContactNo;
            studentDetails.StudentAddress  = student.Address;
            studentDetails.StudentDeptCode = deptCode;
            studentDetails.StudentDeptName = deptName;
            studentDetails.StudentDate     = student.Date;

            ViewBag.StudentDetails = studentDetails;

            // ViewBag.StudentDetails = aStudentManager.GetStudentbyDetailsById(student.DepartmentId, student.StudentId);
            // Session["StudentDetails"] = ViewBag.StudentDetails;


            return(View());
        }
 public StudentDetails(int primarykey)
 {
     InitializeComponent();
     objviewmodel     = new StudentSearchViewModel(primarykey);
     this.DataContext = objviewmodel;
     string dir = System.Environment.CurrentDirectory;
 }
Exemple #8
0
        // GET: Student/Details/5
        public ActionResult Details(Guid id)
        {
            if (!UserIsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var result = _studentQuery.Handle(new StudentInputGetById {
                StudentId = id
            });
            var student = new StudentDetailsViewModel
            {
                Id        = result.Student.Id,
                CPF       = result.Student.CPF.Number,
                Email     = result.Student.Email.Address,
                FirstName = result.Student.FirstName,
                LastName  = result.Student.LastName,
                Phone     = result.Student.Phone,
                Address   = result.Student.Address,
                City      = result.Student.City,
                Birthdate = result.Student.Birthdate,
                Country   = result.Student.Country,
                Course    = result.Student.Course.Name,
                Gender    = result.Student.Gender
            };

            return(View(student));
        }
Exemple #9
0
        public async Task <IActionResult> StudentDetails(long Id)
        {
            Student      student = studentRepository.FindStudentById(Id);
            IdentityUser user    = await userManager.FindByIdAsync(student.IdentityUserId);

            student.IdentityUser = user;
            StudentAccademicInformation accademicInformation = studentRepository.FindStudentAccademicInformationById(student.Id);
            StudentNextOfKinInformation nextOfKinInformation = studentRepository.FindStudentNextofKinById(student.Id);
            StudentSponsor studentSponsor = studentRepository.FindStudentSponsorById(student.Id);

            if (student == null)
            {
                ViewBag.ErrorMessage = $"The Student with Id = { Id } could not be found";
                return(View("NotFound"));
            }
            StudentDetailsViewModel model = new StudentDetailsViewModel
            {
                Student = student,
                StudentAccademicInformation = accademicInformation,
                StudentSponsor = studentSponsor,
                StudentNextOfKinInformation = nextOfKinInformation
            };

            return(View(model));
        }
        public void StudentCanBeDelete()
        {
            DbContextOptions <Lab13StudentEnrollmentDbContext> options =
                new DbContextOptionsBuilder <Lab13StudentEnrollmentDbContext>()
                .UseInMemoryDatabase(Guid.NewGuid().ToString())
                .Options;

            using (Lab13StudentEnrollmentDbContext context = new Lab13StudentEnrollmentDbContext(options))
            {
                Student student = new Student();
                student.Name     = "Bob";
                student.Age      = 24;
                student.CourseID = "cs201";

                StudentsController sc = new StudentsController(context);
                var x        = sc.Create(student);
                var retrieve = context.Students.Where(s => s.Name == "Bob").ToList();

                ViewResult current           = (ViewResult)sc.Details(retrieve[0].ID).Result;
                StudentDetailsViewModel test = (StudentDetailsViewModel)current.Model;

                Assert.Equal("Bob", test.Student.Name);

                x        = sc.Delete(test.Student.ID);
                retrieve = context.Students.Where(s => s.Name == "Bob").ToList();
                Assert.Empty(retrieve);
            }
        }
        public async Task <StudentDetailsViewModel> FindById(int studentId)
        {
            var student = await this.db.Students
                          //.Include(s=>s.Parents)
                          //.ThenInclude(x=>x.Select(y=>y.Parent))
                          .Include(s => s.Group)
                          .FirstOrDefaultAsync(x => x.Id == studentId && x.Status != StudentStatus.Quit);

            var parents = this.db.Parents.Where(p => p.Children.Any(sp => sp.StudentId == student.Id)).ToArray();

            var model = new StudentDetailsViewModel
            {
                Id            = student.Id,
                FirstName     = student.FirstName,
                MiddleName    = student.MiddleName,
                LastName      = student.LastName,
                Age           = student.Age,
                BirthDate     = student.BirthDate.ToString(Constants.dateOnlyFormat),
                Gender        = student.Gender,
                Grade         = student.Grade,
                GroupId       = (int?)student.GroupId == null ? 0 : student.GroupId,
                GroupName     = student.Group == null ? InfoStrings.StudentNotInAGroupYet : student.Group.Name,
                Status        = student.Status,
                ProfilePicURI = student.ProfilePicURI,
                Parents       = parents.Select(p => new ParentsSelectionViewModel
                {
                    Id   = p.Id,
                    Name = p.FullName
                }).ToList()
            };

            return(model);
        }
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var student = await _context.Students
                          .Include(s => s.User)
                          .Include(s => s.StudDiscs)
                          .SingleOrDefaultAsync(m => m.Id == id);

            if (student == null)
            {
                return(NotFound());
            }

            var selectedDiscId = student.StudDiscs.Select(sd => sd.DisciplineId).ToList();

            var model = new StudentDetailsViewModel {
                Student = student
            };

            model.SelectedDisc = _context.Disciplines
                                 .Include(d => d.Teacher)
                                 .Where(d => selectedDiscId.Contains(d.Id))
                                 .ToList();

            return(View(model));
        }
Exemple #13
0
        public ViewResult Details()
        {
            ViewBag.Title  = "Student Details Page";
            ViewBag.Header = "Student Details";

            Student student = new Student()
            {
                StudentId = 101,
                Name      = "Dillip",
                Branch    = "CSE",
                Section   = "A",
                Gender    = "Male"
            };

            Address address = new Address()
            {
                AddressId = 1,
                City      = "Mumbai",
                State     = "Maharashtra",
                Country   = "India",
                Pin       = "400097"
            };
            StudentDetailsViewModel studentDetailsViewModel = new StudentDetailsViewModel()
            {
                Student = student,
                Address = address,
                Title   = "Student Details Page",
                Header  = "Student Details",
            };

            return(View(studentDetailsViewModel));
        }
Exemple #14
0
 public ActionResult ViewStudentDetails(int id)
 {
     ///Action to View Student Details
     ///id is the Student Id which data has to be fetched
     try
     {
         HttpCookie conString = Request.Cookies.Get("rwxgqlb");                         //get the encrypted connection string from the cookie
         Student    s         = new Student(id, Cryptography.Decrypt(conString.Value)); //initialized a new object with the student id
         //coping the values of student to the view model
         StudentDetailsViewModel sdvm = new StudentDetailsViewModel
         {
             AdmissionNumber = s.AdmissionNumber,
             Age             = s.Age.ToString(),
             BForm           = s.BFormNumber,
             Class           = s.Section.Class.Name,
             Name            = s.Name,
             Section         = s.Section.Name,
             DOA             = s.DateOfAdmission.ToLongDateString(),
             Fee             = decimal.Round(s.MonthlyFee).ToString(),
             FName           = s.Parent.FatherName,
             Gender          = s.Gender + "",
             Id         = s.StudentId,
             PrevInst   = s.PreviousInstitute,
             RollNumber = s.RollNumber.ToString()
         };
         return(View(sdvm)); //return the View with the view model containging the student's values
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
        public ViewResult Details()
        {
            Student student = new Student()
            {
                StudentId  = 101,
                Name       = "Sai Ram Sagar",
                Department = "Computer Science Engineering",
                Gender     = "Male",
                AddressId  = 1001,
                Salary     = 50000
            };

            Address address = new Address()
            {
                AddressId = 1001,
                State     = "AP",
                City      = "Visakhapatnam",
                Country   = "India",
                Pin       = "530013"
            };

            StudentDetailsViewModel sdvm = new StudentDetailsViewModel()
            {
                Student    = student,
                Address    = address,
                PageHeader = "Student details Page",
                PageTitle  = "Student details"
            };

            return(View(sdvm));
        }
Exemple #16
0
        public StudentDetailsViewModel MapToStudentModelDetails(Student student)
        {
            var model = new StudentDetailsViewModel();

            model.Id             = student.Id;
            model.FirstName      = student.FirstName;
            model.LastName       = student.LastName;
            model.Year           = student.Year;
            model.Email          = student.Email;
            model.Country        = student.Country;
            model.Address1       = student.Address1;
            model.Address2       = student.Address2;
            model.City           = student.City;
            model.BirthDay       = student.BirthDay;
            model.Grades         = student.Grades;
            model.Courses        = student.Courses;
            model.StudentClassId = student.StudentClassId;
            model.IsActive       = student.IsActive;
            if (student.StudentClass != null)
            {
                model.StudentClass = student.StudentClass;
            }
            if (student.Courses != null)
            {
                model.Courses = student.Courses;
            }
            return(model);
        }
        public async Task <ActionResult> CreateStudent(StudentDetailsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new StudentDetailsViewModel();
                return(View(viewModel));
            }

            var student = map.MapToStudent(model);

            student.Id       = Guid.NewGuid().ToString();
            student.IsActive = true;

            try
            {
                db.Students.Add(student);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Error"));
            }
        }
Exemple #18
0
        public ActionResult Index()
        {
            StudentDetailsViewModel model = new StudentDetailsViewModel();
            SelectListItem          item  = new SelectListItem()
            {
                Text = "All", Value = "-1"
            };

            model.Enrollments = RestClient.RestClientGet <List <EnrollmentViewModel> >(Constants.BaseUrl, Constants.EnrollmentYearsMethod)
                                .Select(enr => new SelectListItem {
                Text = enr.Enrollment.ToString(), Value = enr.Id.ToString()
            })
                                .ToList();
            model.Services = RestClient.RestClientGet <List <StudentServiceViewModel> >(Constants.BaseUrl, Constants.SchoolServicessMethod)
                             .Select(ser => new SelectListItem {
                Text = ser.ServiceName.ToString(), Value = ser.Id.ToString()
            })
                             .ToList();
            model.Students = RestClient.RestClientGet <List <StudentViewModel> >(Constants.BaseUrl, Constants.StudentsMethod)
                             .Select(std => new SelectListItem {
                Text = std.FullName.ToString(), Value = std.Id.ToString()
            })
                             .ToList();
            model.Enrollments.Insert(0, item);
            model.Services.Insert(0, item);
            model.Students.Insert(0, item);

            return(View(model));
        }
        public ActionResult AddNewSubject(StudentDetailsViewModel vm)
        {
            var allSubject = _graphManager.GetAllGraphs();

            _studentManager.SetActiveSubject(vm.ActualStudent.Id, allSubject.First(x => x.Name == vm.SelectedSubject).Id);
            return(RedirectToAction("StudentsManage"));
        }
Exemple #20
0
        // ~/Secretary/Student/Details/{id}
        public IActionResult Details(int id)
        {
            // Τα στοιχεία ενός φοιτητή

            var student = context.Students.FirstOrDefault(s => s.Id == id);

            if (student == null)
            {
                TempData["ErrorMessage"] = "Ο φοιτητής δε βρέθηκε.";

                return(RedirectToAction("Index", "Student"));
            }

            var direction = context.Directions.FirstOrDefault(d => d.Id == student.DirectionId);

            List <Enrollment> enrollments = context
                                            .Enrollments
                                            .Include(e => e.AcademicPeriod)
                                            .Where(e => e.StudentId == id)
                                            .ToList();

            StudentDetailsViewModel studentdetailsViewModel = new StudentDetailsViewModel()
            {
                Title       = "Στοιχεία φοιτητή " + student.FullName,
                Student     = student,
                Direction   = direction,
                Enrollments = enrollments
            };

            return(View(studentdetailsViewModel));
        }
Exemple #21
0
        public IActionResult Details(int id)
        {
            Student student        = _employeeRepository.GetStudent(id);
            var     studentCourses = _db.StudentCourses.Include(c => c.Course).ToList();


            if (student != null)
            {
                StudentDetailsViewModel model = new StudentDetailsViewModel
                {
                    Name           = student.Name,
                    Email          = student.Email,
                    Gender         = student.Gender,
                    Age            = student.Age,
                    BatchId        = student.BatchId,
                    Status         = student.Status,
                    Type           = student.Type,
                    StudentId      = student.StudentId,
                    Payment        = student.Payment,
                    StudentBatches = student.StudentBatches,
                    Projects       = _project.GetStudentProjectByStudentId(student.StudentId)
                };
                var courses = studentCourses.FindAll(c => c.StudentId == id);

                var guarantors = _employeeRepository.GetAllGuarantors();
                var list       = guarantors.ToList();
                ViewBag.studentGuarantors = list.FindAll(g => g.StudentId == id);
                ViewBag.courses           = courses;
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }
Exemple #22
0
        //Finished
        public StudentDetailsViewModel GetStudentDetails(string studentId)
        {
            var service = this.db.Connect();
            StudentDetailsViewModel result = null;

            try
            {
                using (ServiceContext context = new ServiceContext(service))
                {
                    result = (from student in context.AccountSet
                              where student.New_UserID.Equals(studentId)
                              select new StudentDetailsViewModel
                    {
                        FirstName = student.New_FirstName,
                        LastName = student.New_FamilyName,
                        StudentId = student.New_UserID,
                        StudentStatusValue = student.New_StudentStatus.Value,
                        Program = student.new_programid.Name.ToString(),
                        //ProgramAdvisor = student.new_ProgramAdvisorid.Name
                    })
                             .FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception throw during retrival of students details with message: {ex.Message}");
            }
            return(result);
        }
        public ActionResult StudentDetails(string id)
        {
            var actualStudent = _psychologistManager.GetAllStudents().FirstOrDefault(x => x.Id == id);
            var allSubjects   = _graphManager.GetAllGraphs();
            var VM            = new StudentDetailsViewModel(actualStudent, allSubjects);

            return(View(VM));
        }
Exemple #24
0
        public StudentDetails()
        {
            InitializeComponent();
            var studentId = Application.Current.Properties["StudentId"] as string;
            var viewModel = new StudentDetailsViewModel(studentId);

            DataContext = viewModel;
        }
Exemple #25
0
 private void ClassIniti()
 {
     _preferences             = PreferenceManager.GetDefaultSharedPreferences(Activity);
     _studentDetailsViewModel = new StudentDetailsViewModel();
     _studentDetailsViewModel.OpeartaionEvent += StudentDetailsViewModel_OpeartaionEvent;
     _studentList = new List <StudentDetailsModel>();
     GetStudentList();
 }
Exemple #26
0
        // GET: Students/Details/5
        public ActionResult Details(int id)
        {
            Student student = GetStudentById(id);

            StudentDetailsViewModel viewModel = new StudentDetailsViewModel(id, _config.GetConnectionString("DefaultConnection"));

            viewModel.Student = student;

            return(View(viewModel));
        }
Exemple #27
0
        private void ClassInit()
        {
            _preferences = PreferenceManager.GetDefaultSharedPreferences(Activity);
            IsAdmin      = _preferences.GetBoolean(AppConstant.PrefIsAdmin, false);
            StudentID    = _preferences.GetInt(AppConstant.PrefStudentID, -1);

            _studentDetailsViewModel = new StudentDetailsViewModel();
            _studentDetailsViewModel.OpeartaionEvent += StudentDetailsViewModel_OpeartaionEvent;
            GetStudentData();
        }
        // GET: Student/Create
        public async Task <ActionResult> CreateStudent()
        {
            var model = new StudentDetailsViewModel
            {
                StudentClasses = await db.Classes.ToListAsync(),
                Courses        = await db.Courses.ToListAsync()
            };

            return(View(model));
        }
 /// <summary>
 /// Action that allows the user to view student specific details.
 /// </summary>
 /// <param name="id">Can accept an id or nothing</param>
 /// <returns>Returns a SDVM base on the object id or redirects to index</returns>
 public async Task <IActionResult> Details(int?id)
 {
     if (id.HasValue)
     {
         return(View(await StudentDetailsViewModel.ViewDetails(id.Value, _context)));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Exemple #30
0
 public ActionResult EditStudent(AddStudent2ViewModel model, int sId)
 {
     ///Post Method to get the values submitted from the form
     ///model contains the data of student
     ///sId is the Student Id to recognoize the student and update values
     try
     {
         ViewBag.StudentId = sId;                                                        //send student Id to the view by using the view bag
         HttpCookie conString = Request.Cookies.Get("rwxgqlb");                          //getting the encrypted connection string from the cookie
         Student    s         = new Student(sId, Cryptography.Decrypt(conString.Value)); //initialzed a new object of Student by the student Id to get the data and update it
         try
         {
             //setting the properties of Student obeject with the model values
             s.AdmissionNumber   = model.AddmissionNumber;
             s.BFormNumber       = model.BForm;
             s.DateOfBirth       = model.DOB;
             s.Gender            = model.Gender;
             s.MonthlyFee        = model.MonthlyFee;
             s.Name              = model.Name;
             s.PreviousInstitute = model.Prevnst;
         }
         catch (Exception ex)
         {
             ModelState.AddModelError(string.Empty, ex.Message);
             return(View());
         }
         //copying new values to the Student Details View Model
         StudentDetailsViewModel sdvm = new StudentDetailsViewModel
         {
             AdmissionNumber = s.AdmissionNumber,
             Name            = s.Name,
             Age             = s.Age.ToString(),
             BForm           = s.BFormNumber,
             Class           = s.Section.Class.Name,
             Section         = s.Section.Name,
             DOA             = s.DateOfAdmission.ToLongDateString(),
             Fee             = decimal.Round(s.MonthlyFee).ToString(),
             FName           = s.Parent.FatherName,
             Gender          = s.Gender + "",
             Id         = s.StudentId,
             PrevInst   = s.PreviousInstitute,
             RollNumber = s.RollNumber.ToString()
         };
         ViewBag.Success = true;                   //set the flag for the successful operation
         return(View("ViewStudentDetails", sdvm)); //return STUDENT_DETAILS VIEW with the view model containing the updated values
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
        public ActionResult UpdateStudent()
        {
            // await ParseUser.LogInAsync("*****@*****.**", "123456");
            ParseUser user = Session.GetLoggedInUser();
            StudentDetailsViewModel model = new StudentDetailsViewModel();
            ViewBag.IsAdmin = (user != null && !string.IsNullOrEmpty(Session.GetImpersonatingUserName())) || Session.GetLoggedInUserRoleName() == RoleNames.ADMINISTRATORS;

            if (user == null) return RedirectToAction("Login");

            var repository = new ParseRepository(new WebCacheProvider(HttpContext.ApplicationInstance.Context));
            var worldContentTypeRetriever = new WorldContentTypeRetriver(HttpContext, repository);
            var contentTypes =  worldContentTypeRetriever.GetContentTypes(user, Session.GetLoggedInUserRoleName());
            var currencies = repository.FindCurrencies();
            var uiLanguages =  repository.FindInterfaceLanguages();
            IEnumerable<UserGroup> groups = ( repository.FindGroups()).ToArray();
            IEnumerable<UserGroup> subGroups = ( repository.FindSubGroups()).ToArray();
            var sugLessonPublishingStatus = repository.FindUserPublishingStatus();
            var userStatuses = repository.FindUserStatus();

            model.DeviceTypes =  repository.FindDeviceTypes();
            model.Countries = repository.FindCountries();
            model.UserPrefferences.ContentTypes = contentTypes;
            model.UserPrefferences.Currencies = currencies;
            model.UserPrefferences.Languages = uiLanguages;
            model.Groups = groups;
            model.SubGroups = subGroups;
            model.SugLessonPublishingStatus = sugLessonPublishingStatus;
            model.UserStatusValues = userStatuses;

            model.FirstName = user.GetString("firstName_he_il");// user.Keys.Contains("firstName") ? user["firstName"] as string : string.Empty;
            model.LastName = user.GetString("lastName_he_il");// user.Keys.Contains("lastName") ? user["lastName"] as string : string.Empty;
            model.Email = user.Keys.Contains("email") ? user["email"] as string : string.Empty;
            model.Phone = user.Keys.Contains("phoneNumber") ? user["phoneNumber"] as string : string.Empty;
            model.Email = user.Keys.Contains("email") ? user["email"] as string : string.Empty;
            model.MailRecipientAddress = user.GetString("mailRecipientAddress");
            model.UserPrefferences.SelectedContentType = user.GetPointerObjectId("contentType");
                       
            model.UserPrefferences.SelectedCurrency = user.GetPointerObjectId("currency");
            model.UserPrefferences.SelectedLanguage = user.GetPointerObjectId("interfaceLanguage");
            
            model.CountryOfResidence = user.GetPointerObjectId("residenceCountry");

            model.SelectedDeviceType = user.Keys.Contains("deviceType") && (user["deviceType"] as ParseObject) != null ? (user["deviceType"] as ParseObject).FetchIfNeededAsync().Result.ObjectId : string.Empty;
            model.SelectedDeviceType = model.DeviceTypes.FirstOrDefault(deviceType => deviceType.Key.Split(new [] { '|' })[0] == model.SelectedDeviceType).Key;

            ViewBag.DeviceUnSupportedText =  Strings.GetLocalizedString(Strings.UnSupportedDevice);

            var userAdminData =  user.GetPointerObject<UserAdminData>("adminData");
            if (userAdminData != null)
            {
                model.AdminData.TCPTeacherCommission = userAdminData.TcpTeacherCommission.ToString("n2");
                model.AdminData.AgentUserName =userAdminData.Agent!=null? userAdminData.Agent.Username:string.Empty;
                model.AdminData.ACPAgentCommission = userAdminData.AcpTeacherCommission.ToString("n2");
                model.AdminData.STRCommissionRatio = userAdminData.StrCommissionRatio;
                model.AdminData.UserPublishingStatus = userAdminData.GetPointerObjectId("userPublishingStatus");
                model.AdminData.UserStatus = userAdminData.GetPointerObjectId("userStatus");
                model.AdminData.LockCountry = userAdminData.LockCountry;
                model.AdminData.LockCurrency = userAdminData.LockCurrency;
                model.AdminData.AdminRemarks = userAdminData.AdminRemarks;
                if (userAdminData.Group != null)
                {
                    var savedSelectedGroup = userAdminData.Group.ObjectId;
                    var selectedSubGroup = subGroups.SingleOrDefault(o => o.ObjectId == savedSelectedGroup);
                    var selectedGroup = groups.SingleOrDefault(o => o.ObjectId == savedSelectedGroup);
                    if (selectedSubGroup != null)
                    {
                        selectedGroup = groups.Single(o => o.ObjectId == selectedSubGroup.Parent.ObjectId);
                    }

                    model.AdminData.Group = selectedGroup != null ? selectedGroup.ObjectId : string.Empty;
                    model.AdminData.SubGroup = selectedSubGroup != null ? selectedSubGroup.ObjectId : string.Empty;
                }
            }

            model.Messages.CountryLocked = Strings.GetLocalizedString(Strings.CountryLocked);
            model.Messages.SugOsekLocked = Strings.GetLocalizedString(Strings.SugOsekLocked);
            model.Messages.CurrencyLocked = Strings.GetLocalizedString(Strings.CurrencyLocked);
            model.Messages.SugNirutLocked = Strings.GetLocalizedString(Strings.SugNirutLocked);
            model.Messages.AgentNotFound = Strings.GetLocalizedString(Strings.AgentNotFound);
            if (user.GetStatus() == UserStatusStrings.AppUser)
            {
                model.AppUserMessage = string.Format(MyMentorResources.appUserMoreDetails, user.GetFullName(Language.CurrentLanguageCode));
            }
            return View(model);
        }
        public async Task<ActionResult> UpdateStudent(StudentDetailsViewModel model)
        {
            var repository = RepositoryFactory.GetInstance(Session);
            try
            {
                var registerAsTeacher = model.RegisterAsTeacher;

                ViewBag.IsAdmin = (Session.GetLoggedInUser() != null && !string.IsNullOrEmpty(Session.GetImpersonatingUserName())) || Session.GetLoggedInUserRoleName() == RoleNames.ADMINISTRATORS;

                IEnumerable<UserGroup> groups = (repository.FindGroups()).ToArray();
                IEnumerable<UserGroup> subGroups = (repository.FindSubGroups()).ToArray();
                var sugLessonPublishingStatus = repository.FindUserPublishingStatus();
                var userStatuses = repository.FindUserStatus();
                var worldContentTypeRetriever = new WorldContentTypeRetriver(HttpContext, repository);
                
                model.UserRole = RoleNames.STUDENTS;
                model.DeviceTypes = repository.FindDeviceTypes();
                model.Countries = repository.FindCountries();

                model.UserPrefferences.ContentTypes = worldContentTypeRetriever.GetContentTypes(Session.GetLoggedInUser(), Session.GetImpersonatingUserName());
                model.UserPrefferences.Currencies = repository.FindCurrencies();
                model.UserPrefferences.Languages = repository.FindInterfaceLanguages();
                model.Groups = groups;
                model.SubGroups = subGroups;
                model.SugLessonPublishingStatus = sugLessonPublishingStatus;
                model.UserStatusValues = userStatuses;
               // var selectedCountry = model.Countries.FirstOrDefault(country => country.Key == model.CountryOfResidence);
               // model.CountryOfResidence = selectedCountry;
                try
                {
                    await new MyMentorUserManager(repository, Session).UpdateStudent(model);
                    model.UpdateSuccess = true;
                }
                catch (Exception ex)
                {
                    mLogger.Log(LogLevel.Error, ex.ToString);
                    model.UpdateSuccess = false;
                }

                if (model.UpdateSuccess != null)
                {
                    if (registerAsTeacher)
                    {
                        ViewBag.UpdateStudentMessage = model.UpdateSuccess.Value ?
                             Strings.GetLocalizedString(Strings.RegistrationSuccessStudentBucomesTeacher) :
                             Strings.GetLocalizedString(Strings.UpdateStudentFail);

                        if (model.UpdateSuccess.Value) ViewBag.UpdateStudentMessage = string.Format(ViewBag.UpdateStudentMessage, model.FirstName);
                    }
                    else
                    {
                        ViewBag.UpdateStudentMessage = model.UpdateSuccess.Value ?
                             Strings.GetLocalizedString(Strings.UpdateStudentSuccess) :
                             Strings.GetLocalizedString(Strings.UpdateStudentFail);
                    }

                }

                SetUserPrefferences(model.UserPrefferences);

                return View(model);
            }
            finally 
            {
                repository.Dispose();
            }
        }