Exemple #1
0
        public async Task <IActionResult> EditStudentProfile([FromBody] EditProfileVM student)
        {
            //Get Request's User
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;

            if (!claimsIdentity.IsAuthenticated)
            {
                return(Unauthorized());
            }
            //Get Student Profile
            var claim     = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier);
            var userEmail = claim.Value;
            var User      = await _userManager.FindByEmailAsync(userEmail);

            student.ApplicationUserId = User.Id;

            Student studentToEdit = new Student();

            studentToEdit.Id                = student.Id;
            studentToEdit.Info              = student.Info;
            studentToEdit.Title             = student.Title;
            studentToEdit.Universty         = student.Universty;
            studentToEdit.School            = student.School;
            studentToEdit.SchholYearFrom    = student.SchholYearFrom;
            studentToEdit.SchholYearTo      = student.SchholYearTo;
            studentToEdit.UniverstyYearFrom = student.UniverstyYearFrom;
            studentToEdit.UniverstyYearTo   = student.UniverstyYearTo;
            studentToEdit.ApplicationUserId = User.Id;
            studentToEdit.Image             = student.Image;
            ApplicationUser userToEdit = new ApplicationUser();

            userToEdit           = User;
            userToEdit.Gender    = student.Gender;
            userToEdit.BirthDate = Convert.ToDateTime(student.Birthdate);
            userToEdit.Name      = student.Username;
            var updatedProfileInfo = _profileSrv.EditProile(studentToEdit, userToEdit);

            return(Ok(new { Status = "Success", ProfileInfo = new {
                                Image = updatedProfileInfo.Image,
                                Info = updatedProfileInfo.Info,
                                School = updatedProfileInfo.School,
                                Universty = updatedProfileInfo.Universty,
                                Username = User.Name,
                                SchoolYearFrom = student.SchholYearFrom,
                                SchoolYearTo = student.SchholYearTo,
                                UniverstyYearFrom = student.UniverstyYearFrom,
                                UniverstyYearTo = student.UniverstyYearTo,
                                Gender = User.Gender,
                                BirthDate = User.BirthDate.ToString("MM/dd/yyyy")
                            } }));
        }
Exemple #2
0
        public async Task <IActionResult> EditStudentProfile([FromBody] Student student)
        {
            //Get Request's User
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;

            if (!claimsIdentity.IsAuthenticated)
            {
                return(Unauthorized());
            }
            //Get Student Profile
            var claim     = claimsIdentity.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier);
            var userEmail = claim.Value;
            var User      = await _userManager.FindByEmailAsync(userEmail);

            student.ApplicationUserId = User.Id;
            var updatedProfileInfo = _profileSrv.EditProile(student);

            return(Ok(new { Status = "Success", ProfileInfo = new {
                                Image = updatedProfileInfo.Image,
                                Info = updatedProfileInfo.Info,
                                School = updatedProfileInfo.School,
                                Universty = updatedProfileInfo.Universty
                            } }));
        }