Ejemplo n.º 1
0
        public new ActionResult Profile()
        {
            UserService         userService    = new UserService();
            UnitOfWork          uow            = new UnitOfWork();
            var                 userId         = Session["UserId"].ToString();
            TeacherProfileModel teacherProfile = uow.TeacherRepository.GetTeacherProfile(userId);

            ViewBag.TeacherStages         = uow.TeacherRepository.GetTeacherStages(userId);
            ViewBag.TeacherQualifications = uow.TeacherQualifications.Get(a => a.TeacherID == userId).ToList();
            ViewBag.TeacherCertification  = uow.TeacherCertifications.Get(a => a.TeacherId == userId).ToList();
            ViewBag.TeacherLanguages      = uow.TeacherRepository.GetTeacherLanguages(userId);
            ViewBag.Stages                   = uow.Stages.Get().ToList();
            ViewBag.Years                    = new Common().GetYearsList();
            ViewBag.LanguageLevels           = GetLanguageLevel();
            ViewBag.Languages                = uow.Languages.Get(x => x.IsActive == true).ToList();
            teacherProfile.AccountDetail     = uow.TeacherAccountDetails.Get(x => x.TeacherId == userId).FirstOrDefault();
            teacherProfile.MemberSince       = Convert.ToDateTime(uow.Users.GetByID(userId).CreationDate).ToString("MMMM yyyy");
            teacherProfile.HoursSpent        = 6;
            teacherProfile.ClassesTaught     = 2;
            teacherProfile.QuestionsAnswered = 12;
            if (teacherProfile != null)
            {
                teacherProfile.Email = Encryptor.Decrypt(teacherProfile.Email);
                return(View(teacherProfile));
            }
            return(RedirectToAction("Index", "Home"));
        }
        public IActionResult GetProfile([FromRoute] int userId)
        {
            var user      = _userFacade.GetUser(userId);
            var sanctions = _sanctionFacade.GetAllActiveOfUser(userId).ToList();

            ProfileResponse response;
            var             userProfile = new UserProfileModel(user.UserProfile.Name, user.UserProfile.Email,
                                                               user.UserProfile.AboutUser, user.UserProfile.BirthYear, user.UserProfile.Gender,
                                                               user.UserProfile.IsTeacher, user.UserProfile.AvatarLink, user.UserProfile.Contacts, sanctions);

            if (user.UserProfile.IsTeacher)
            {
                var reviews = new List <ReviewModel>();
                user.TeacherProfile.Reviews.ToList().ForEach(r =>
                {
                    reviews.Add(new ReviewModel(r.FromUser, r.Title, r.Text, r.Date, r.FromGroup));
                });
                var teacherProfile = new TeacherProfileModel(reviews,
                                                             user.TeacherProfile.Skills);
                response = new ProfileResponse(userProfile, teacherProfile);
            }
            else
            {
                response = new ProfileResponse(userProfile);
            }

            return(Ok(response));
        }
Ejemplo n.º 3
0
        public ActionResult TeacherProfile()
        {
            var model = new TeacherProfileModel();

            model = ProfileManageRepo.loadTeacherProfile(HttpUtil.UserProfile.ID);
            return(View(model));
        }
Ejemplo n.º 4
0
 public ProfileResponse(UserProfileModel userProfile, TeacherProfileModel teacherProfile)
 {
     UserProfile    = userProfile;
     TeacherProfile = teacherProfile;
 }
Ejemplo n.º 5
0
        public new ActionResult Profile(TeacherProfileModel profile, HttpPostedFileBase file)
        {
            UnitOfWork  uow         = new UnitOfWork();
            UserService userService = new UserService();
            var         userId      = Session["UserId"].ToString();

            ViewBag.TeacherStages         = uow.TeacherRepository.GetTeacherStages(userId.ToString());
            ViewBag.TeacherQualifications = uow.TeacherQualifications.Get(a => a.TeacherID == userId).ToList();
            ViewBag.TeacherCertification  = uow.TeacherCertifications.Get(a => a.TeacherId == userId).ToList();
            ViewBag.Stages = uow.Stages.Get().ToList();
            User user = userService.GetProfile(userId);

            if (file != null)
            {
                profile.ProfileImage = Guid.NewGuid().ToString() + Path.GetFileName(file.FileName);
                string path = Path.Combine(Server.MapPath("~/Content/images/"), profile.ProfileImage);
                file.SaveAs(path);
                //byte[] bytes;
                //using (BinaryReader br = new BinaryReader(file.InputStream))
                //{
                //    bytes = br.ReadBytes(file.ContentLength);
                //}
                Session["Picture"] = profile.ProfileImage;
                user.Picture       = profile.ProfileImage;
            }
            if (user != null)
            {
                if (user.Email != Encryptor.Encrypt(profile.Email))
                {
                    string Token = Encryptor.Encrypt(DateTime.Now.Ticks.ToString());
                    user.ValidationToken = Token;
                    var    scheme   = Request.Url.Scheme + "://";
                    var    host     = Request.Url.Host + ":";
                    var    port     = Request.Url.Port;
                    string host1    = scheme + host + port;
                    string bodyHtml = "<p>Welcome to Chill Learn</p> <p> please <a href='" + host1 + "/account/emailconfirmation?token=" + Token + "'>Click Here</a> to confirm email </p>";
                    user.Status = (int)UserStatus.Pending;
                    uow.UserRepository.SendEmail(profile.Email, "Chill Learn Recover Password", bodyHtml);
                }
                user.Email         = Encryptor.Encrypt(profile.Email);
                user.FirstName     = profile.FirstName;
                user.LastName      = profile.LastName;
                user.Address       = profile.Address;
                user.City          = profile.City;
                user.Country       = profile.Country;
                user.ContactNumber = profile.FullPhone;
                user.UpdateDate    = DateTime.Now;
                uow.Users.Update(user);

                TeacherDetail teacherDetail = uow.TeacherDetails.Get(a => a.TeacherID == user.UserID).FirstOrDefault();
                if (teacherDetail != null)
                {
                    teacherDetail.University      = profile.Title;
                    teacherDetail.Qualification   = profile.Qualification;
                    teacherDetail.YearsExperience = profile.Experience;
                    teacherDetail.Description     = profile.Description;
                    uow.TeacherDetails.Update(teacherDetail);
                }
                else
                {
                    TeacherDetail teacher = new TeacherDetail
                    {
                        University      = profile.Title,
                        Description     = profile.Description,
                        CreationDate    = DateTime.Now,
                        Qualification   = profile.Qualification,
                        Status          = 1,
                        YearsExperience = profile.Experience,
                        TeacherID       = userId
                    };
                    uow.TeacherDetails.Insert(teacher);
                }

                uow.Save();
            }
            //profile.ContactNumber = profile.FullPhone;
            //return View(profile);
            return(RedirectToAction("profile", "tutor"));
        }
Ejemplo n.º 6
0
        public TeacherProfileModel loadTeacherProfile(int userID)
        {
            var result = new TeacherProfileModel();

            result.AcademicResult = new List <string>();
            try
            {
                //var objToSave = DbContext.UserInfos.FirstOrDefault(u => (u.Email == emailOrUserName || u.UserName == emailOrUserName) && u.Password == password);
                var userInfo = DbContext.UserInfos.FirstOrDefault(u => u.ID == userID);
                var teacher  = DbContext.Teachers.FirstOrDefault(s => s.T_ID == userID);
                var academic = DbContext.AcademicResults.FirstOrDefault(a => a.T_ID == userID);
                var subject  = DbContext.Subjects.Where(s => s.T_ID == userID).ToList();

                result.Email = userInfo.Email;
                result.Name  = userInfo.Name;
                string experties = "";


                foreach (var v in subject)
                {
                    experties += v.SubjectName + ",";
                }
                if (experties.EndsWith(","))
                {
                    experties = experties.Remove(experties.Length - 1, 1);
                }

                result.Experties = experties;
                if (academic == null)
                {
                    result.AcademicResult.Add("");
                    result.AcademicResult.Add("");
                    result.AcademicResult.Add("");
                }
                else
                {
                    try
                    {
                        result.AcademicResult.Add(academic.S_Result.ToString());
                    }catch (Exception ex)
                    {
                        result.AcademicResult.Add("");
                    }

                    try
                    {
                        result.AcademicResult.Add(academic.C_Result.ToString());
                    }
                    catch (Exception ex)
                    {
                        result.AcademicResult.Add("");
                    }
                    try
                    {
                        result.AcademicResult.Add(academic.V_Result.ToString());
                    }
                    catch (Exception ex)
                    {
                        result.AcademicResult.Add("");
                    }
                }

                if (teacher == null)
                {
                    result.ContactNo   = "";
                    result.Description = "";
                    result.Location    = "";
                }
                else
                {
                    result.ContactNo   = teacher.ContactNo;
                    result.Description = teacher.Description;
                    result.Location    = teacher.Location;
                }
            }
            catch (Exception ex)
            {
                result = null;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public Result <List <PendingRequestModel> > AllPendingRequests(int S_id)
        {
            var result = new Result <List <PendingRequestModel> >();

            result.Data = new List <PendingRequestModel>();
            var Myposts = DbContext.Posts.Where(p => p.S_ID == S_id && p.isActive == 1).OrderByDescending(o => o.Post_Time).ToList();

            try
            {
                foreach (var v in Myposts)
                {
                    var PendingRequests = new PendingRequestModel();

                    PendingRequests.P_ID        = v.P_ID;
                    PendingRequests.description = v.Description;
                    result.Data.Add(PendingRequests);
                }
                foreach (var v in result.Data)
                {
                    var teachers = DbContext.Requests.Where(u => u.P_ID == v.P_ID).ToList();
                    v.TeacherList = new List <TeacherProfileModel>();
                    foreach (var v1 in teachers)
                    {
                        var UserInfo            = DbContext.UserInfos.FirstOrDefault(u => u.ID == v1.T_ID);
                        var teacher             = DbContext.Teachers.FirstOrDefault(u => u.T_ID == v1.T_ID);
                        var teacherProfileModel = new TeacherProfileModel();
                        try
                        {
                            teacherProfileModel.ContactNo = teacher.ContactNo;
                        }
                        catch (Exception ex)
                        {
                            teacherProfileModel.ContactNo = "";
                        }
                        try
                        {
                            teacherProfileModel.Email = UserInfo.Email;
                        }
                        catch (Exception ex)
                        {
                            teacherProfileModel.Email = "";
                        }
                        try
                        {
                            teacherProfileModel.Location = teacher.Location;
                        }
                        catch (Exception ex)
                        {
                            teacherProfileModel.Location = "";
                        }
                        teacherProfileModel.Name = UserInfo.Name;
                        v.TeacherList.Add(teacherProfileModel);
                    }
                }
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }