public IActionResult Index()
        {
            PersonalInfoView personalInfo = null;
            var user = db.Users.FirstOrDefault(u => u.Login == HttpContext.User.Identity.Name);

            if (user != null)
            {
                if (user.UserType == "Student")
                {
                    user.State = new StateUserStudent();
                }
                else if (user.UserType == "Teacher")
                {
                    user.State = new StateUserTeacher();
                }

                user.GetUserPersonalInfo(db, out personalInfo);

                personalInfo.AvatarPath = Path.Combine(path, user.Avatar);

                ViewData["UserType"] = user.UserType;
            }

            return(View(personalInfo));
        }
Example #2
0
        public void UpdatePersonalInfo_ItShouldUpdatePersonalInfoDetails_Success()
        {
            var userId = new PersonalInfoView()
            {
                UserId        = 13600,
                BirthDate     = new DateTime(1978, 08, 03),
                GenderItemId  = 51002,
                Email         = "*****@*****.**",
                PhoneNumber   = "+97511111222",
                LanguageKnown = new List <LanguageItemView>
                {
                    new LanguageItemView()
                    {
                        ProfileId         = 15985,
                        LanguageItemId    = 98001,
                        ProficiencyItemId = 99001
                    },
                    new LanguageItemView()
                    {
                        ProfileId         = 15985,
                        LanguageItemId    = 98002,
                        ProficiencyItemId = 99002
                    }
                }
            };

            var mm = _profileService.UpdatePersonalInfoAsync(userId).Result;

            Assert.IsTrue(mm.Success);
        }
Example #3
0
        public void GetUserPersonalInfo(User user, SchoolContext context, out PersonalInfoView personalInfo)
        {
            var person = context.Students.FirstOrDefault(s => s.UserGUID == user.GUID);

            personalInfo = new PersonalInfoView();

            personalInfo.FIO       = person.FIO;
            personalInfo.DateBirth = person.DateBirth.ToShortDateString();
            int age = DateTime.Now.Year - person.DateBirth.Year;

            if (DateTime.Now.Month < person.DateBirth.Month ||
                (DateTime.Now.Month == person.DateBirth.Month && DateTime.Now.Day < person.DateBirth.Day))
            {
                age--;
            }
            personalInfo.Age         = age.ToString();
            personalInfo.Telephone   = person.Telephone;
            personalInfo.UserType    = user.UserType;
            personalInfo.NumberClass = context.Classes.FirstOrDefault(c => c.Id == person.ClassId).NumberClass;
        }
Example #4
0
        public void GetUserPersonalInfo(User user, SchoolContext context, out PersonalInfoView personalInfo)
        {
            var person = context.Teachers.FirstOrDefault(t => t.UserGUID == user.GUID);

            personalInfo = new PersonalInfoView();

            personalInfo.FIO       = person.FIO;
            personalInfo.DateBirth = person.DateBirth.ToShortDateString();
            int age = DateTime.Now.Year - person.DateBirth.Year;

            if (DateTime.Now.Month < person.DateBirth.Month ||
                (DateTime.Now.Month == person.DateBirth.Month && DateTime.Now.Day < person.DateBirth.Day))
            {
                age--;
            }
            personalInfo.Age         = age.ToString();
            personalInfo.Telephone   = person.Telephone;
            personalInfo.UserType    = user.UserType;
            personalInfo.SubjectName = context.Subjects.FirstOrDefault(s => s.Id == person.SubjectId).SubjectName;
        }
Example #5
0
 /// <summary>
 /// Creates a success response.
 /// </summary>
 /// <param name="personalInfo">personalInfo view model.</param>
 /// <returns>Response.</returns>
 public ProfileResponse(PersonalInfoView personalInfo) : this(true, ClientMessageConstant.Success, personalInfo)
 {
 }
Example #6
0
 private ProfileResponse(bool success, string message, PersonalInfoView personalInfo) : base(success, message)
 {
     PersonalInfoView = personalInfo;
 }
Example #7
0
        public async Task <IActionResult> UpdatePersonalInfoAsync([FromBody] PersonalInfoView model)
        {
            var result = await _service.UpdatePersonalInfoAsync(model);

            return(Ok(result));
        }
Example #8
0
 public void GetUserPersonalInfo(SchoolContext context, out PersonalInfoView personalInfo)
 {
     State.GetUserPersonalInfo(this, context, out personalInfo);
 }