Beispiel #1
0
        public string AceptarTutor(TutorViewModel tutor)
        {
            string mensaje = "";

            mensaje = negocios.AceptarTutor(tutor.id);
            return(mensaje);
        }
Beispiel #2
0
        public int CreateTutor(TutorViewModel tvm)
        {
            Tutor tu = new Tutor();

            tu.Name        = tvm.Name;
            tu.DOB         = tvm.DOB;
            tu.Nationality = tvm.Nationality;
            tu.HourlyRate  = tvm.HourlyRate;
            tu.Contact     = tvm.Contact;
            tu.EmailId     = tvm.EmailId;
            tu.Photo       = tvm.Photo;
            tu.Address     = tvm.Address;
            tu.SubjectId   = tvm.SubjectId;

            _db.Tutors.Add(tu);
            _db.SaveChanges();

            Qualification qf = new Qualification();

            qf.TutorId   = tu.TutorId;
            qf.Instution = tvm.Instution;
            qf.Board     = tvm.Board;
            qf.StartDate = tvm.StartDate;
            qf.EndDate   = tvm.EndDate;
            qf.CGPA      = tvm.CGPA;
            _db.Qualifications.Add(qf);
            return(_db.SaveChanges());
        }
Beispiel #3
0
        public TutorViewModel GetTutorbyEmailId(string emaild)
        {
            Tutor          tu  = _db.Tutors.Where(s => s.EmailId == emaild).FirstOrDefault();
            TutorViewModel tvm = new TutorViewModel();

            if (tu != null)
            {
                Qualification qf = _db.Qualifications.Where(q => q.TutorId == tu.TutorId).FirstOrDefault();

                if (tu != null)
                {
                    tvm.TutorId     = tu.TutorId;
                    tvm.Name        = tu.Name;
                    tvm.DOB         = tu.DOB;
                    tvm.Nationality = tu.Nationality;
                    tvm.HourlyRate  = tu.HourlyRate;

                    tvm.Contact   = tu.Contact;
                    tvm.Photo     = tu.Photo;
                    tvm.Address   = tu.Address;
                    tvm.SubjectId = tu.SubjectId;

                    if (qf != null)
                    {
                        tvm.Instution = qf.Instution;
                        tvm.Board     = qf.Board;
                        tvm.StartDate = qf.StartDate;
                        tvm.EndDate   = qf.EndDate;
                        tvm.CGPA      = qf.CGPA;
                    }
                }
            }
            return(tvm);
        }
Beispiel #4
0
        public int UpdateTutor(TutorViewModel tvm)
        {
            Tutor tu = _db.Tutors.Where(t => t.EmailId == tvm.EmailId).FirstOrDefault();

            tu.Name        = tvm.Name;
            tu.DOB         = tvm.DOB;
            tu.Nationality = tvm.Nationality;
            tu.HourlyRate  = tvm.HourlyRate;
            tu.Contact     = tvm.Contact;
            tu.EmailId     = tvm.EmailId;
            tu.Photo       = tvm.Photo;
            tu.Address     = tvm.Address;
            tu.SubjectId   = tvm.SubjectId;



            Qualification qf = _db.Qualifications.Where(t => t.TutorId == tu.TutorId).FirstOrDefault();

            qf.Instution = tvm.Instution;
            qf.Board     = tvm.Board;
            qf.StartDate = tvm.StartDate;
            qf.EndDate   = tvm.EndDate;
            qf.CGPA      = tvm.CGPA;
            return(_db.SaveChanges());
        }
Beispiel #5
0
        public TutorViewModel ObtenerTutorxId2(int id)
        {
            TutorViewModel tutor        = null;
            string         sqlStatement = "SP_OBTENERTUTORXID2";
            SqlCommand     comando      = new SqlCommand(sqlStatement, conexion);

            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@id_tutor", id);
            conexion.Open();
            SqlDataReader reader = comando.ExecuteReader();

            if (reader.HasRows)
            {
                tutor = new TutorViewModel();
                while (reader.Read())
                {
                    tutor.id           = int.Parse(reader["id"].ToString());
                    tutor.nombre       = reader["nombre"].ToString();
                    tutor.apellido     = reader["apellido"].ToString();
                    tutor.direccion    = reader["direccion"].ToString();
                    tutor.email        = reader["email"].ToString();
                    tutor.clave        = reader["clave"].ToString();
                    tutor.curriculum   = reader["curriculum"].ToString();
                    tutor.antecedentes = reader["antecedentes"].ToString();
                    tutor.recibo       = reader["recibo"].ToString();
                    tutor.foto         = reader["foto"].ToString();
                    tutor.fecha        = reader["FechaFormato"].ToString();
                }
            }
            conexion.Close();
            return(tutor);
        }
        public ActionResult Details(int id)
        {
            TutorProfile tutor = _dbContext.TutorProfiles.Find(id);

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

            TutorViewModel model = new TutorViewModel();

            model.Name                = tutor.Name;
            model.ImagePath           = tutor.ImagePath;
            model.Department          = tutor.Department;
            model.CurrentYear         = tutor.CurrentYear;
            model.AdmissionSession    = tutor.AdmissionSession;
            model.ExpectedSalaryRange = tutor.ExpectedSalaryRange;
            model.Hall                = tutor.Hall;
            model.InterestedArea      = tutor.InterestedArea;
            model.InterestedClass     = tutor.InterestedClass;
            model.InterestedSubject   = tutor.InterestedSubject;
            model.PermanentAddress    = tutor.ParmanentAddress;
            model.PresentAddress      = tutor.PresentAddress;

            return(View(model));
        }
Beispiel #7
0
        public async Task Post(TutorViewModel model)
        {
            var content = new StringContent(JsonConvert.SerializeObject(model), System.Text.Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync("api/tutor", content);

            response.EnsureSuccessStatusCode();
        }
Beispiel #8
0
        public DefaultRespuesta AddTutor(TutorViewModel vmTutor)
        {
            DefaultRespuesta vmRsta = new DefaultRespuesta(true, "Don't Save");

            try
            {
                Tutor tutor = new Tutor();
                tutor.ID_Usuario   = vmTutor.IdUsuario;
                tutor.Experiencia  = vmTutor.Experiencia;
                tutor.Costo        = vmTutor.Costo;
                tutor.Calificacion = vmTutor.Calificacion;
                tutor.Direccion    = vmTutor.Direccion;
                tutor.Telefono     = vmTutor.Telefono;
                tutor.Estado       = 1;

                context.Tutor.Add(tutor);
                context.SaveChanges();

                vmRsta = new DefaultRespuesta(false, "Save Sussesfull");
            }
            catch
            {
                vmRsta = new DefaultRespuesta(true, "Fail Conexion");
            }

            return(vmRsta);
        }
Beispiel #9
0
        public TutorViewModel GetTutorById(int id)
        {
            var            lista = negocios.ObtenerTutorxId();
            TutorViewModel tutor = lista.FirstOrDefault(x => x.id == id);

            return(tutor);
        }
Beispiel #10
0
        public ActionResult Edit(int id)
        {
            var academicMajorResult = _academicMajorService.Get();

            if (!academicMajorResult.Success)
            {
                var status = new StatusModel(false, academicMajorResult.Message);
                return(Error(status));
            }
            var academicInstitutionResult = _academicInstitutionService.Get(CurrentUser.Area);

            if (!academicInstitutionResult.Success)
            {
                var status = new StatusModel(false, academicMajorResult.Message);
                return(Error(status));
            }
            TutorViewModel model = new TutorViewModel
            {
                AcademicInstitutionList = academicInstitutionResult.Data,
                AcademicMajorList       = academicMajorResult.Data,
                Tutor = new TutorModel()
            };

            ViewBag.IsRackaz = CurrentUser.UserRole == UserRole.Rackaz;
            ViewBag.IsCreate = false;
            var result = _tutorService.Get(id);

            if (result.Success)
            {
                model.Tutor = result.Data;
            }

            return(View(model));
        }
Beispiel #11
0
        public async Task <ActionResult> Availability()
        {
            var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

            TutorViewModel model = await _tutorService.GetTutorAvailabilityAsync(_user);

            return(View(model));
        }
        public ActionResult Create()
        {
            TutorViewModel viewModel = new TutorViewModel();

            viewModel.StudentAppointment = new StudentAppointment();
            viewModel.Tutors             = tutors.Collection();
            viewModel.ClassGroupings     = classes.Collection();
            return(View(viewModel));
        }
 public int Update(TutorViewModel model)
 {
     if (ModelState.IsValid)
     {
         var tutor = _mapper.Map <Tutor>(model);
         _repository.Update(tutor);
         return(tutor.Id);
     }
     return(0);
 }
Beispiel #14
0
        public TutorViewModel GetTutorbyTutorId(int tutorid)
        {
            Tutor          tu  = _db.Tutors.Where(s => s.TutorId == tutorid).FirstOrDefault();
            TutorViewModel tvm = new TutorViewModel();

            tvm.TutorId     = tu.TutorId;
            tvm.Name        = tu.Name;
            tvm.DOB         = tu.DOB;
            tvm.Nationality = tu.Nationality;
            tvm.HourlyRate  = tu.HourlyRate;
            return(tvm);
        }
Beispiel #15
0
 public ActionResult Index(TutorViewModel tvm)
 {
     ViewBag.SaveText = "Save";
     if (ModelState.IsValid)
     {
         if (Session["action"].ToString() == "Save")
         {
             HttpPostedFileBase fup = Request.Files["Photo"];
             if (fup != null)
             {
                 tvm.Photo = fup.FileName;
                 string filename = Path.GetFileName(fup.FileName);
                 fup.SaveAs(Server.MapPath("~/TutorImages/" + filename));
             }
             tvm.EmailId = Session["emailid"].ToString();
             int i = tudb.CreateTutor(tvm);
             if (i > 0)
             {
                 ViewBag.SaveText = "Update";
                 ViewBag.Message  = "Saved Successfully";
                 //return Content("tutor Created Successfully", "text/html");
             }
         }
         else
         {
             tvm.EmailId = Session["emailid"].ToString();
             HttpPostedFileBase fup = Request.Files["Photo"];
             if (fup != null)
             {
                 tvm.Photo = fup.FileName;
                 string filename = Path.GetFileName(fup.FileName);
                 fup.SaveAs(Server.MapPath("~/TutorImages/" + filename));
             }
             int i = tudb.UpdateTutor(tvm);
             if (i > 0)
             {
                 ViewBag.SaveText = "Update";
                 ViewBag.Message  = "Updated Successfully";
                 //return Content("Tutor updated Successfully", "text/html");
             }
         }
     }
     //else
     //{
     //
     //}
     ViewBag.Subjects = subdb.GetAllSubject();
     return(View());
 }
        public ActionResult Edit(string Id)
        {
            StudentAppointment studentAppointment = context.Find(Id);

            if (studentAppointment == null)
            {
                return(HttpNotFound());
            }
            else
            {
                TutorViewModel viewModel = new TutorViewModel();
                viewModel.StudentAppointment = studentAppointment;
                viewModel.Tutors             = tutors.Collection();
                viewModel.ClassGroupings     = classes.Collection();
                return(View(viewModel));
            }
        }
Beispiel #17
0
        public ActionResult Index()
        {
            TutorViewModel tvm = tudb.GetTutorbyEmailId(Session["emailid"].ToString());

            Session.Add("tutorid", tvm.TutorId.ToString());
            ViewBag.Subjects = subdb.GetAllSubject();
            if (tvm.TutorId > 0)
            {
                ViewBag.SaveText = "Update";
                Session.Add("action", "Update");
            }
            else
            {
                ViewBag.SaveText = "Save";
                Session.Add("action", "Save");
            }
            return(View(tvm));
        }
Beispiel #18
0
        // GET: Tutor/Dashboard
        public async Task <ActionResult> Index()
        {
            var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

            TutorViewModel model = await _tutorService.GetTutorAvailabilityAsync(_user);

            model.SessionsList = await _sessionService.GetSessionByTutorIdAsync(_user.Id);

            AccountService accountService = new AccountService();

            if (model.SessionsList != null && model.SessionsList.Count > 0)
            {
                for (int i = 0; i < model.SessionsList.Count; i++)
                {
                    model.SessionsList[i].TutorName = await accountService.GetFullName(model.SessionsList[i].UserId);
                }
            }
            return(View(model));
        }
Beispiel #19
0
        public async Task <ActionResult> DeclineSession(int?id)
        {
            var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

            if (id != null && id > 0)
            {
                DBManage.DBHandler dbHandler = new DBManage.DBHandler();
                dbHandler.TranscatData("update Sessions set status=2 where id=" + id + "");
            }
            TutorViewModel model = new TutorViewModel()
            {
                UserId = _user.Id,
                User   = _user
            };

            model.SessionsList = await _sessionService.GetSessionByTutorIdAsync(_user.Id);

            return(View("Index", model));
        }
Beispiel #20
0
        public async Task <ActionResult> Availability(TutorViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _tuitionService.SetAvailabilityAsync(model);

                    ModelState.Clear();
                    ViewBag.success = "<ul><li><p style='color:green'>Successfully Submitted!! Thanks for providing information.</p></li></ul>";

                    var t = Task.Run(() =>
                    {
                        try
                        {
                            var _subject = "Tuition Availability - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org";
                            var _body    = "<b>Tutor Availability Updation</b><br><br/> "
                                           + "Tutor : <b>" + model.User.FirstName + " " + model.User.LastName + "</b><br/>"
                                           + "Tutor has updated Tuition Availability Information. <br/>"
                                           + "Comment/Concerns: " + model.Concerns + "<br/><br/>"
                                           + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> @ " + DateTime.Now.Year;

                            EmailSender.SendEmail(_subject, _body);
                            SMSSender.SMSSenderAsync("Tutor " + model.User.FirstName + " " + model.User.LastName + " just updated tuition availability time.");
                        }
                        catch { }
                    });

                    return(View(model));
                }
                catch (Exception ex)
                {
                    ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + ex.Message + "</p></li></ul>";
                    return(View(model));
                }
            }
            else
            {
                var error = ModelState.FirstOrDefault(x => x.Value.Errors.Count > 0).Value.Errors.First().ErrorMessage;
                ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + error + "</p></li></ul>";
            }
            return(View(model));
        }
Beispiel #21
0
        // GET: Tutor/Session
        public async Task <ActionResult> Index()
        {
            var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

            TutorViewModel model = await _tutorService.GetTutorAvailabilityAsync(_user);

            var _sessionRequests = await _tuitionService.GetSessionByTutorUserIdAsync(_user.Id);

            _sessionRequests.ForEach(x =>
            {
                model.SessionRequests.Add(new SessionRequestsViewModel()
                {
                    Session       = x,
                    TutorUserId   = x.TutorUserId,
                    StudentUserId = x.UserId,
                    StudentUser   = x.User
                });
            });

            return(View(model));
        }
Beispiel #22
0
        public ActionResult RequestTutor(int tutorProfileID)
        {
            if (Session["AllliveUser"] != null)
            {
                var myUser = (UserModel)Session["AllliveUser"];
                ViewBag.myUserID = myUser.UserId;
            }

            var tutor = Dc.TutorProfiles.Find(tutorProfileID);

            if (tutor != null)
            {
                var user = Dc.Users.Find(tutor.UserID);
                var VM   = new TutorViewModel(tutor, user);
                return(View(VM));
            }
            else
            {
                return(RedirectToAction("SearchTutor"));
            }
        }
Beispiel #23
0
        public ActionResult Create()
        {
            ViewBag.IsCreate = true;
            var academicMajorResult = _academicMajorService.Get();

            if (!academicMajorResult.Success)
            {
                var status = new StatusModel(false, academicMajorResult.Message);
                return(Error(status));
            }
            var academicInstitutionResult = _academicInstitutionService.Get(CurrentUser.Area);

            if (!academicInstitutionResult.Success)
            {
                var status = new StatusModel(false, academicMajorResult.Message);
                return(Error(status));
            }
            TutorViewModel model = new TutorViewModel
            {
                AcademicInstitutionList = academicInstitutionResult.Data,
                AcademicMajorList       = academicMajorResult.Data,
                Tutor = new TutorModel()
                {
                    // Birthday = DateTime.Now
                }
            };

            model.Tutor.User = new UserModel();
            if (CurrentUser.UserRole == UserRole.Admin)
            {
                ViewBag.IsRackaz = false;
            }
            else
            {
                model.Tutor.User.Area = CurrentUser.Area;
                ViewBag.IsRackaz      = true;
            }

            return(View(model));
        }
Beispiel #24
0
        public ActionResult Details(int id)
        {
            TutorViewModel tutor = new TutorViewModel();

            if (tutor.Profile == null)
            {
                return(new RedirectToRouteResult(
                           new RouteValueDictionary(
                               new
                {
                    area = "Default",
                    controller = "Home",
                    action = "Index"
                }
                               )
                           ));
            }
            TutorProfile tutorProfile = TutorDB.FetchProfile(id);

            tutor.Profile = tutorProfile;
            return(View(tutor));// new { data= "Tutor data" });
        }
Beispiel #25
0
        public List <TutorViewModel> ListaTutoresPendientes()
        {
            List <TutorViewModel> usuarios = null;

            conexion.Open();

            string     query   = "SP_LISTA_TUTORES_PENDIENTES";
            SqlCommand comando = new SqlCommand(query, conexion);

            comando.CommandType = CommandType.StoredProcedure;

            SqlDataReader lector = comando.ExecuteReader();

            if (lector.HasRows)
            {
                usuarios = new List <TutorViewModel>();

                while (lector.Read())
                {
                    var u = new TutorViewModel();
                    u.id           = int.Parse(lector["Id"].ToString());
                    u.nombre       = lector["Nombre"].ToString();
                    u.apellido     = lector["Apellido"].ToString();
                    u.direccion    = lector["Direccion"].ToString();
                    u.email        = lector["Email"].ToString();
                    u.clave        = lector["Clave"].ToString();
                    u.foto         = lector["Foto"].ToString();
                    u.curriculum   = lector["Curriculum"].ToString();
                    u.recibo       = lector["Recibo"].ToString();
                    u.antecedentes = lector["Antecedentes"].ToString();
                    u.fecha        = lector["FechaFormato"].ToString();

                    usuarios.Add(u);
                }
            }

            conexion.Close();
            return(usuarios);
        }
Beispiel #26
0
        public ActionResult BookNow(int id)
        {
            Session.Add("scheduleid", id.ToString());

            HireViewModel hrv       = new HireViewModel();
            DateTime      todaydate = DateTime.Today;

            hrv.StartDate = todaydate;

            DateTime enddate = DateTime.Today.AddDays(30);

            hrv.EndDate = DateTime.Today.AddMonths(1);

            TutorViewModel tvm         = tdb.GetTutorbyTutorId(Convert.ToInt32(Session["teacherid"].ToString()));
            decimal?       rateperhour = tvm.HourlyRate;


            hrv.TotalFee = rateperhour * 30;


            return(View(hrv));
        }
Beispiel #27
0
        public JsonResult GetAmount(DateTime starDate, DateTime endDate)
        {
            //HireViewModel hr = new HireViewModel();
            //DateTime? startd = hr.StartDate;
            //DateTime? endd = hr.EndDate;

            DateTime       fromdate    = starDate;
            DateTime       todate      = endDate;
            TimeSpan       ts          = todate.Subtract(fromdate);
            var            a           = ts.Days;
            TutorViewModel tvm         = tdb.GetTutorbyTutorId(Convert.ToInt32(Session["teacherid"].ToString()));
            decimal?       rateperhour = tvm.HourlyRate;



            decimal?totalamt = a * rateperhour;

            //HireViewModel hrv = new HireViewModel();
            //hrv.TotalFee = totalamt;

            return(Json(totalamt, JsonRequestBehavior.AllowGet));
        }
Beispiel #28
0
        public async Task <ActionResult> Schedule(TutorSessionViewModel model)
        {
            int insertedID = 0;

            if (ModelState.IsValid)
            {
                try
                {
                    var sessionInfo    = string.Empty;
                    int DayTimeChecked = 0;
                    if (model.SessionSchedules != null)
                    {
                        foreach (var schedule in model.SessionSchedules)
                        {
                            foreach (var time in schedule.Timing)
                            {
                                if (time.Selected)
                                {
                                    DayTimeChecked += 1;
                                    sessionInfo    += "<b>" + schedule.Day.ToString() + "</b>&nbsp;&nbsp;&nbsp;<b>" + time.Time + "</b>&nbsp;&nbsp;&nbsp;<b><br/>";
                                }
                            }
                        }
                    }
                    if (DayTimeChecked < 2)
                    {
                        ViewBag.success = "<ul><li><p style='color:red'>Validation ERROR: Please choose atleast 2+ Days/Times that you are available.</p></li></ul>";
                        model.Students  = GetStudents();
                        return(View("Schedule", model));
                    }

                    var message = "New Session has been scheduled.";
                    if (model.Id > 0)
                    {
                        (bool success, TutorSessionViewModel data) = await _scheduleService.UpdateScheduleAsync(model);

                        insertedID = data.Id;
                        if (success == false)
                        {
                            ViewBag.success = "<ul><li><p style='color:red'>ERROR: Session Doesn't Exist.</p></li></ul>";
                            model.Students  = GetStudents();
                            return(View("Schedule", model));
                        }
                        message = "A scheduled session has been updated.";
                    }
                    else
                    {
                        (bool success, TutorSessionViewModel data) = await _scheduleService.CreateScheduleAsync(model);

                        insertedID = data.Id;
                    }

                    var _subject = "Tutor Session Schedule Info - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org";
                    var _body    = "<p>Greetings,</p>";
                    _body += "<p>" + model.Title.ToUpper() + "</p>";
                    _body += "<p>Tutor: " + model.User.FirstName + " " + model.User.LastName + " is requesting a session for the following days</p>";
                    _body += "<p><span style='text - decoration: underline;'>AVAILABLE ON :</span></p>";
                    _body += "<p>" + sessionInfo + "</p>";
                    _body += "<p>if you would like to approve it click the below link.</p>";
                    _body += "<p>";
                    _body += "<a href='" + ConfigurationManager.AppSettings["SiteURL"] + "?action=approve&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'>" +
                             "'" + ConfigurationManager.AppSettings["SiteURL"] + "?action=approve&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'</p>";
                    _body += "<p>if you would like to decline the tutor request, you can click the below link :</p>";
                    _body += "<a href='" + ConfigurationManager.AppSettings["SiteURL"] + "?action=decline&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'>" +
                             "'" + ConfigurationManager.AppSettings["SiteURL"] + "?action=decline&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'</p>";
                    _body += "<p>--</p>";
                    _body += "<p>Regards from&nbsp;<a href='http://instanttutors.org/' target='_blank' rel='noopener'>Intant Tutors Team</a> &nbsp;</p>";
                    _body += "<p>&nbsp;</p>";
                    _body += "<p>Mark&nbsp;<a href='http://instanttutors.org/Inappropriate?action=Inappropriate&Fromid=" + model.UserId + "&Forid=" + model.Student + "' target='_blank' rel='noopener'>Inappropriate</a>&nbsp; , report to administrator</p>";

                    var    _userInfo = UserManager.FindByIdAsync(model.Student);
                    string emailTo   = utilityService.GetEmailAddress(model.Student);

                    await EmailSender.SendEmailAsync(_subject, _body, emailTo);

                    //await SMSSender.SMSSenderAsync(message + " Tutor name is " + model.User.FirstName + " " + model.User.LastName);

                    ModelState.Clear();
                    //ViewBag.success = "<div class='alert alert-success'><strong>Success!</strong> Session info successfully submitted.</div>";
                    //model.Students = GetStudents();


                    ViewBag.success = "<div class='alert alert-success'><strong>Success!</strong> " + message + "</div>";
                    //model.Tutors = GetTutors();
                    System.Threading.Thread.Sleep(1000);
                    var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

                    TutorViewModel _tutorViewModel = new TutorViewModel()
                    {
                        UserId = _user.Id,
                        User   = _user
                    };
                    _tutorViewModel.SessionsList = await _sessionService.GetSessionByTutorIdAsync(_user.Id);

                    return(View("Index", _tutorViewModel));
                }
                catch (Exception ex)
                {
                    ViewBag.success = "<div class='alert alert-danger'><strong>ERROR!</strong> " + ex.Message + ".</div>";
                    model.Students  = GetStudents();
                    return(View("Schedule", model));
                }
            }
            model.Students = GetStudents();
            return(View("Schedule", model));
        }
Beispiel #29
0
        public async Task <TutorViewModel> GetTutorAvailabilityAsync(ApplicationUser _user, string userid = "")
        {
            //var _user = await UserManager.FindByEmailAsync(User.Identity.Name);
            string userID;

            if (string.IsNullOrEmpty(userid))
            {
                userID = _user.Id;
            }
            else
            {
                userID = userid;
            }

            var _tutor = await this.GetTutorByUserIdAsync(userID);

            _tutor = _tutor == null ? new Tutors() : _tutor;

            TutorViewModel model = new TutorViewModel()
            {
                NameOfSchool     = _tutor.NameOfSchool,
                Experience       = _tutor.Experience,
                PreviousSubjects = _tutor.PreviousSubjects,
                UserId           = _tutor.UserId,
                Concerns         = _tutor.Concerns,
                GradeLevel       = _tutor.GradeLevel,
                //CreatedDate = _tutor.CreatedDate,
                Id   = _tutor.Id,
                User = _user
            };
            var TuitionSubjects = new List <TuitionSubjectsViewModel>()
            {
                new TuitionSubjectsViewModel {
                    Name = "K-5th", Description = "K-5th", Selected = false, TutorId = _tutor.Id
                },
                new TuitionSubjectsViewModel {
                    Name = "6th-8th", Description = "6th-8th", Selected = false, TutorId = _tutor.Id
                },
                new TuitionSubjectsViewModel {
                    Name = "FSA/EOC", Description = "FSA/EOC", Selected = false, TutorId = _tutor.Id
                },
                new TuitionSubjectsViewModel {
                    Name = "World Languages (Spanish)", Description = "World Languages (Spanish)", Selected = false, TutorId = _tutor.Id
                }
            };

            if (_tutor.TuitionSubjects.Count > 0)
            {
                foreach (var sub in _tutor.TuitionSubjects)
                {
                    var subject = TuitionSubjects.FirstOrDefault(x => x.Name == sub.Name);
                    if (subject != null)
                    {
                        subject.Id       = sub.Id;
                        subject.Selected = true;
                    }
                }
            }
            model.TuitionSubjects = TuitionSubjects;

            var TutorAvailability = new List <TutorAvailabilityViewModel>();

            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)).OfType <DayOfWeek>().ToList().Skip(1))
            {
                TutorAvailability.Add(new TutorAvailabilityViewModel()
                {
                    //Id
                    TutorId = _tutor.Id,
                    Timing  = Utils.Common.GetTiming(),
                    Day     = day
                });
            }
            if (_tutor.TutorAvailability != null)
            {
                if (_tutor.TutorAvailability.Count > 0)
                {
                    foreach (var avail in TutorAvailability)
                    {
                        foreach (var _time in avail.Timing)
                        {
                            var availTime = _tutor.TutorAvailability.FirstOrDefault(x => x.Time == _time.AvailabilityTime && x.Day == avail.Day);
                            if (availTime != null)
                            {
                                avail.Id       = availTime.Id;
                                _time.Selected = true;
                                avail.Time     = availTime.Time;
                            }
                        }
                    }
                }
            }
            model.TutorAvailability = TutorAvailability;

            return(model);
        }
Beispiel #30
0
        // GET: MainPage
        public ActionResult MainPage()
        {
            //a esta pagina solo se puede acceder si ha iniciado sesion
            if (Session["UserGroup"] != null)
            {
                //se guarda el grupo en una variable para luego usarla en los query
                string group = Session["UserGroup"].ToString();

                //se crea un tutor del viewModel
                TutorViewModel objTutor = new TutorViewModel();

                #region OBTENER FOTO DEL TUTOR
                //query que en realidad obtiene el CURP del tutor
                var queryFoto = (from t in dbCtx.Tutors
                                 join cg in dbCtx.ClassGroups on t.ID equals cg.TutorID
                                 where @group == cg.GroupID
                                 select new
                {
                    CURP = t.CURP
                }).SingleOrDefault();

                //al CURP se le agrega el .jpg
                string path = queryFoto.CURP.ToString() + ".JPEG";

                //se agrega al tutor
                objTutor.PhotoPath = path;
                #endregion

                #region OBTENER INFORMACION DEL TUTOR
                //se obtiene la informacion necesaria del tutor
                var queryTutor = (from t in dbCtx.Tutors
                                  join cg in dbCtx.ClassGroups on t.ID equals cg.TutorID
                                  join ms in dbCtx.MaritalStatuses on t.MaritalStatusID equals ms.ID
                                  where @group == cg.GroupID
                                  select new
                {
                    idEmpleado = t.EmployeeID,
                    nombre = t.FirstMidName,
                    apellidoP = t.LastNameP,
                    apellidoM = t.LastNameM,
                    birthDate = t.BirthDate,
                    curp = t.CURP,
                    rfc = t.RFC,
                    maritalStatus = ms.Description,
                    perPhone = t.PersonalPhone,
                    perEmail = t.PersonalEmail,
                    emerPhone = t.EmergencyPhone,
                    academEmail = t.AcademicEmail
                }).SingleOrDefault();

                //se agrega al tutor
                objTutor.EmployeeID     = queryTutor.idEmpleado;
                objTutor.Nombre         = queryTutor.apellidoP + " " + queryTutor.apellidoM + " " + queryTutor.nombre;
                objTutor.FirstMidName   = queryTutor.nombre;
                objTutor.LastNameP      = queryTutor.apellidoP;
                objTutor.LastNameM      = queryTutor.apellidoM;
                objTutor.BirthDate      = queryTutor.birthDate;
                objTutor.CURP           = queryTutor.curp;
                objTutor.RFC            = queryTutor.rfc;
                objTutor.MaritalStatus  = queryTutor.maritalStatus;
                objTutor.PersonalPhone  = queryTutor.perPhone;
                objTutor.EmergencyPhone = queryTutor.emerPhone;
                objTutor.PersonalEmail  = queryTutor.perEmail;
                objTutor.AcademicEmail  = queryTutor.academEmail;

                #endregion

                #region EDITAR VULNERABILIDADES ACADEMICAS DE LOS ALUMNOS
                //el query va a buscar todos los alumnos que tengan alguna unidad con NA de cualquier materia
                var queryStudents = (from s in dbCtx.Students
                                     join cg in dbCtx.ClassGroups on s.ClassGroupID equals cg.ID
                                     join sc in dbCtx.StudentCourses on s.ID equals sc.StudentID
                                     where @group == cg.GroupID && sc.Grade == "NA"
                                     select new
                {
                    student = sc.StudentID,
                    name = s.FirstMidName + " " + s.LastNameP + " " + s.LastNameM
                }).ToList();

                //por cada estudiante con alguna unidad en NA
                foreach (var student in queryStudents)
                {
                    //se va a buscar el registro en la tabla de vulnerabilidades
                    var studentVul = (from sv in dbCtx.StudentVulnerabilities
                                      where sv.StudentID == student.student && sv.VulnerabilityID == 1
                                      select sv).SingleOrDefault();

                    //si el estudiante no tiene vulnerabilidad academica marcada
                    if (studentVul.VulStatus == 0)
                    {
                        //se va a cambiar a vulnerable academico
                        studentVul.VulStatus = 1;
                        //se le va a poner un comentario default que el tutor despues podrá cambiar
                        //si el estudiante ya era vulnerable entonces el comentario que haya puesto el tutor no va a cambiar, por eso la validacion del if
                        studentVul.VulComments = "Estudiante con NA en alguna unidad";

                        //se guardan los cambios
                        dbCtx.Entry(studentVul).State = EntityState.Modified;
                        dbCtx.SaveChanges();

                        //LOG
                        //Buscar la carpeta en el proyecto
                        var pathLog = Server.MapPath("~") + @"Files";
                        //nombre del archivo
                        //como aparecia FilesLog.txt se le agregó la diagonal
                        var fileName = "/Log.txt";

                        StreamWriter sw = new StreamWriter(pathLog + fileName, true);
                        //Permite escribir en el archivo .txt
                        sw.WriteLine("Metodo: MainPageVulnerabilitiesEdit -" + DateTime.Now + "- Se editó la vulnerabilidad academica del estudiante: " + student.name);
                        //cierra la conexion
                        sw.Close();
                    }
                }

                #endregion

                #region OBTENER GRAFICA

                //se va a obtener el estudiante y la cantidad de vulnerabilidades que tiene
                var queryVulnerables = (from s in dbCtx.Students
                                        join sv in dbCtx.StudentVulnerabilities on s.ID equals sv.StudentID
                                        join cg in dbCtx.ClassGroups on s.ClassGroupID equals cg.ID
                                        where @group == cg.GroupID
                                        group sv by s.ID into g
                                        select new
                {
                    student = g.Key,
                    //como se agrupa por estudiante va a sumar sus vulnerabilidades
                    vulnerable = g.Sum(x => x.VulStatus)
                }).ToList();

                //Recorrer el resultado de la consulta anteriormente realizada
                //separar vulnerables y no vulnerables
                int vulnerables   = 0;
                int noVulnerables = 0;
                foreach (var item in queryVulnerables)
                {
                    //si el alumno tiene una o mas vulnerabilidades entonces se cuenta en los vulnerables
                    if (item.vulnerable > 0)
                    {
                        vulnerables++;
                    }
                    //si el alumno no tiene vulnerabilidades entonces se cuenta en los no vulnerables
                    if (item.vulnerable == 0)
                    {
                        noVulnerables++;
                    }
                }

                //guardamos los resultados en viewData para usarlos en la vista
                ViewData["Vulnerables"]   = vulnerables;
                ViewData["NoVulnerables"] = noVulnerables;

                //para el drilldown vamos a ver cuantos alumnos hay por vulnerabilidad
                var queryVulnerablesDetail = (from sv in dbCtx.StudentVulnerabilities
                                              join v in dbCtx.Vulnerabilities on sv.VulnerabilityID equals v.ID
                                              join s in dbCtx.Students on sv.StudentID equals s.ID
                                              join cg in dbCtx.ClassGroups on s.ClassGroupID equals cg.ID
                                              //se contaran solo las del grupo y que tengan mas de 1
                                              where @group == cg.GroupID && sv.VulStatus == 1
                                              group sv by v.Description into g
                                              select new
                {
                    vulnerability = g.Key,
                    quantity = g.Count()
                }).ToList();

                //variables para almacenar la cantidad de alumnos por vulnerabilidad
                //se inicia en 0 por que si no hay alumnos entonces no aparecen en el query
                int academica   = 0;
                int economica   = 0;
                int psicologica = 0;
                int transporte  = 0;
                foreach (var vul in queryVulnerablesDetail)
                {
                    //la cantidad se almacena dependiendo la vulnerabilidad
                    if (vul.vulnerability.ToString() == "Académica")
                    {
                        academica = vul.quantity;
                    }
                    if (vul.vulnerability.ToString() == "Económica")
                    {
                        economica = vul.quantity;
                    }
                    if (vul.vulnerability.ToString() == "Psicológica")
                    {
                        psicologica = vul.quantity;
                    }
                    if (vul.vulnerability.ToString() == "Transporte")
                    {
                        transporte = vul.quantity;
                    }
                }
                //guardamos los resultados en viewData para usarlos en la vista
                ViewData["Transporte"]  = transporte;
                ViewData["Psicológica"] = psicologica;
                ViewData["Económica"]   = economica;
                ViewData["Académica"]   = academica;
                #endregion

                //retornamos la vista con el tutor a usar
                return(View(objTutor));
            }
            else
            {
                //si no ses inicio sesion no se puede acceder a esta pagina
                return(RedirectToAction("Login", "Login"));
            }
        }