예제 #1
0
 public bool UpdateProfile(MentorProfile profile)
 {
     try
     {
         var prof = new MentorProfile
         {
             MentorId   = profile.MentorId,
             Name       = profile.Name,
             LinkedinId = profile.LinkedinId,
             Experience = profile.Experience,
             TimeSlot   = profile.TimeSlot
         };
         context.Mentorprofiles.Add(prof);
         int result = context.SaveChanges();
         if (result > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw;
     }
 }
예제 #2
0
 public IActionResult UpdateProfile([FromBody] MentorProfile profile)
 {
     if (ModelState.IsValid)
     {
         bool result = repository.UpdateProfile(profile);
         if (result)
         {
             return(Created("UpdateProfile", profile.Id));
         }
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
     return(BadRequest(ModelState));
 }
예제 #3
0
        public int UpdateMentorProfile(MentorScheduleModel msm)
        {
            List <subject> sl = new List <subject>();
            subject        s  = (from us in context.subjects where us.id == msm.subject select us).FirstOrDefault();

            sl.Add(s);
            User          u  = (from us in context.Users where us.ID == msm._mentorId select us).FirstOrDefault();
            MentorProfile mp = (from us in context.MentorProfiles where us.fk_mentor_ID == msm._mentorId select us).FirstOrDefault();

            mp.description = msm.description;
            mp.imgPath     = msm.imgpath;
            mp.major       = msm.major;
            foreach (subject st in u.subjects)
            {
                sl.Remove(st);
            }
            if (sl.Count > 0)
            {
                u.subjects = sl;
            }
            List <MentorSchedule> msList = (from r in context.MentorSchedules
                                            where r.fk_mentor_Id == msm._mentorId
                                            select r).ToList();

            for (int i = 0; i <= 6; i++)
            {
                for (int j = 0; j < msm._schedule[i]._timeandRequest.Count; j++)
                {
                    MentorSchedule msr = (from so in msList where so.fk_day_Id == msm._schedule[i].day & so.fk_time_id == msm._schedule[i]._timeandRequest[j].timeId select so).FirstOrDefault();
                    msr.isMentoring = msm._schedule[i]._timeandRequest[j].isMentorAvailable;
                }
            }
            try
            {
                return(context.SaveChanges());
            }
            catch (Exception e)
            {
                return(0);
            }
        }
예제 #4
0
        public void RegisterNewUser(RegisterModel regMod)
        {
            User user = new User();

            user.fname     = regMod.FirstName;
            user.lname     = regMod.LastName;
            user.UserID    = regMod.UserName;
            user.Password  = regMod.Password;
            user.addr1     = regMod.Address1;
            user.addr2     = regMod.Address2;
            user.city      = regMod.City;
            user.state     = regMod.State;
            user.zip       = regMod.ZipCode;
            user.phNo      = regMod.PhoneNumber;
            user.user_type = regMod.EnrollAs;

            context.Users.Add(user);
            if (regMod.EnrollAs == 1)
            {
                MentorProfile mp = new MentorProfile();
                mp.description = null;
                mp.imgPath     = "/Uploads/UserImage/m1.jpeg";
                mp.major       = null;
                mp.User        = user;
                context.MentorProfiles.Add(mp);

                List <weekday> weekdays = context.weekdays.Select(w => w).ToList();
                List <time>    times    = context.times.Select(w => w).ToList();
                foreach (weekday w in weekdays)
                {
                    foreach (time t in times)
                    {
                        MentorSchedule ms = new MentorSchedule();
                        ms.fk_day_Id        = w.dayid;
                        ms.fk_time_id       = t.timeid;
                        ms.MentorProfile    = mp;
                        ms.fk_mentorship_id = null;
                        ms.isMentoring      = 0;
                        context.MentorSchedules.Add(ms);
                    }
                }
            }
            else if (regMod.EnrollAs == 2)
            {
                StudentProfile mp = new StudentProfile();
                mp.description = null;
                mp.imgPath     = "/Uploads/UserImage/m2.jpeg";
                mp.clas        = null;
                mp.User        = user;
                context.StudentProfiles.Add(mp);
                List <weekday> weekdays = context.weekdays.Select(w => w).ToList();
                List <time>    times    = context.times.Select(w => w).ToList();
                foreach (weekday w in weekdays)
                {
                    foreach (time t in times)
                    {
                        StudentSchedule ms = new StudentSchedule();
                        ms.fk_day_Id        = w.dayid;
                        ms.fk_time_id       = t.timeid;
                        ms.StudentProfile   = mp;
                        ms.fk_mentorship_id = null;
                        context.StudentSchedules.Add(ms);
                    }
                }
            }
            context.SaveChanges();
        }
예제 #5
0
        // GET: mentor
        public ActionResult profile()
        {
            if (Session["UserEmail"] != null)
            {
                if (Session["UserType"].ToString() == "Mentor")
                {
                    SqlCommand cmd = new SqlCommand("SelectMentorIsProfile", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@email", Session["UserEmail"].ToString());
                    con.Open();
                    var IsProfile = cmd.ExecuteScalar();
                    con.Close();
                    if (IsProfile != null)
                    {
                        if (IsProfile.ToString() == "True")
                        {
                            SqlCommand cmd1 = new SqlCommand("SelectMentorProfile", con);
                            cmd1.CommandType = CommandType.StoredProcedure;

                            cmd1.Parameters.AddWithValue("@email", Session["UserEmail"].ToString());
                            con.Open();

                            SqlDataReader dr = cmd1.ExecuteReader();
                            dr.Read();
                            if (dr.HasRows)
                            {
                                MentorProfile mp = new MentorProfile
                                {
                                    Name                    = dr["Name"].ToString(),
                                    PrimaryIndustry         = dr["PrimaryIndustry"].ToString(),
                                    BusinessMgtExp          = dr["BusinessMgtExp"].ToString(),
                                    BusinessExpCountry      = dr["BusinessExpCountry"].ToString(),
                                    OwnershipMgtExp         = dr["OwnershipMgtExp"].ToString(),
                                    Achievements            = dr["Achievements"].ToString(),
                                    AreaOfExperties         = dr["AreaOfExperties"].ToString(),
                                    BusinessProblemInterest = dr["BusinessProblemInterest"].ToString(),
                                    AdvisingActivities      = dr["AdvisingActivities"].ToString(),
                                    StageOfBusiness         = dr["StageOfBusiness"].ToString(),
                                    WebLink                 = dr["WebLink"].ToString(),
                                    YourCompany             = dr["YourCompany"].ToString(),
                                    YourRole                = dr["YourRole"].ToString(),
                                    Language                = dr["Language"].ToString(),
                                    Country                 = dr["Country"].ToString(),
                                    State                   = dr["State"].ToString(),
                                    City                    = dr["City"].ToString(),
                                    Pin        = dr["Pin"].ToString(),
                                    IsInvestor = dr["IsInvestor"].ToString(),
                                    Email      = dr["Email"].ToString(),
                                    Mobile     = dr["Mobile"].ToString(),

                                    Image = dr["Image"].ToString()
                                };
                                ViewData["MyMP"] = mp;
                                return(View());
                            }
                            else
                            {
                                return(RedirectToAction("register_info", "mentor"));
                            }
                        }
                        else
                        {
                            return(RedirectToAction("register_info", "mentor"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("login", "user"));
                    }
                }
                else
                {
                    SqlCommand cmd = new SqlCommand("SelectStartupIsProfile", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@email", Session["UserEmail"].ToString());
                    con.Open();
                    var IsProfile = cmd.ExecuteScalar();
                    con.Close();
                    if (IsProfile != null)
                    {
                        if (IsProfile.ToString() == "True")
                        {
                            return(View());
                        }
                        else
                        {
                            return(RedirectToAction("register_info", "startup"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("login", "user"));
                    }
                }
            }
            else
            {
                return(RedirectToAction("login", "user"));
            }
        }