public async Task <ActionResult <ScheduleDto> > PostSchedule([FromBody] CreateScheduleDto scheduleDTO)
        {
            var resSchedule = await _scheduleService
                              .CreateScheduleAsync(scheduleDTO);

            return(resSchedule.ToActionResult());
        }
        public async Task CreateSchedule([FromBody] CreateScheduleRequestViewModel request)
        {
            var model       = Mapper.Map <CreateScheduleRequestViewModel, CreateScheduleRequestDto>(request);
            var currentUser = await _userService.GetUserByName(HttpContext.User.Identity.Name);

            model.DoctorId = currentUser.Id;

            await _scheduleService.CreateScheduleAsync(model);

            HttpContext.Response.StatusCode = (int)HttpStatusCode.Created;
        }
Beispiel #3
0
        public async Task <ActionResult> Schedule(AdminSessionViewModel 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>" + model.CommunicationMethod + "</b>&nbsp;&nbsp;&nbsp;<b>(" + model.Title + ")</b><br/><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.Tutors    = GetTutors();
                        return(View("NewSchedule", model));
                    }

                    var message = "New Session has been scheduled.";
                    if (model.Id > 0)
                    {
                        (bool success, AdminSessionViewModel 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.Tutors    = GetTutors();
                            return(View("NewSchedule", model));
                        }
                        message = "A scheduled session has been updated.";
                    }
                    else
                    {
                        (bool success, AdminSessionViewModel data) = await _scheduleService.CreateScheduleAsync(model);

                        insertedID = data.Id;
                    }

                    var t = Task.Run(() =>
                    {
                        try
                        {
                            var _subject = "Student Session Schedule Info - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org";
                            var _body    = "<a class='navbar-brand' href='/'><img src='http://www.instanttutors.org/Content/images/logo.png' style='width:240px;' /></a>";
                            _body       += "<p>Greetings,</p>";
                            _body       += "<p>" + model.Title.ToUpper() + "</p>";
                            _body       += "<p>Student: " + 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>";


                            string emailTo  = utilityService.GetEmailAddress(model.Student);
                            string emailTo1 = utilityService.GetEmailAddress(model.Tutor);
                            EmailSender.SendEmailAdmin(_subject, _body, emailTo, emailTo1);
                            SMSSender.SMSSenderAsync(message + " Student name is " + model.User.FirstName + " " + model.User.LastName);
                        }
                        catch { }
                    });

                    ModelState.Clear();
                    ViewBag.success = "<div class='alert alert-success'><strong>Success!</strong> " + message + "</div>";

                    var _user = await UserManager.FindByEmailAsync(User.Identity.Name);

                    StudentViewModel _studentViewModel = new StudentViewModel()
                    {
                        UserId = _user.Id,
                        User   = _user
                    };
                    _studentViewModel.SessionsList = await _sessionService.GetSessionAdminAsync(_user.Id);

                    return(View("Index1", _studentViewModel));
                    //return View("SelectTiming", model);
                }
                catch (Exception ex)
                {
                    ViewBag.success = "<div class='alert alert-danger'><strong>ERROR!</strong> " + ex.Message + ".</div>";
                    model.Tutors    = GetTutors();
                    model.Students  = GetStudents();
                    return(View("NewSchedule", model));
                }
            }
            model.Tutors   = GetTutors();
            model.Students = GetStudents();
            return(View("NewSchedule", model));
        }
Beispiel #4
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 #5
0
        public async Task <ActionResult> Schedule(SessionViewModel model)
        {
            model.TutorsList = model.TutorsList == null ? await _sessionService.GetTutorsAsync() : model.TutorsList;

            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>" + model.CommunicationMethod + "</b>&nbsp;&nbsp;&nbsp;<b>(" + model.Title + ")</b><br/><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>";
                        return(View(model));
                    }

                    var message = "New Session has been scheduled.";
                    try { model.CreatedBy = User.Identity.GetUserId(); } catch { }
                    if (model.Id > 0)
                    {
                        (bool success, SessionViewModel data) = await _scheduleService.UpdateScheduleAsync(model);

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

                    //var t = Task.Run(() =>
                    //{
                    try
                    {
                        var tutorInfo = await UserManager.FindByIdAsync(model.TutorUserId);

                        var _subject = "New Session Scheduled - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org";
                        var _body    = "<h3>" + message + "</h3>"
                                       + "<b>Student Name:</b> " + model.User.FirstName + " " + model.User.LastName + "<br/>"
                                       + "<b>Email:</b> " + model.User.Email + "<br/>"
                                       + "<b>Mobile:</b> " + model.User.PhoneNumber + "<br/>"
                                       + "<b>Session Title:</b> " + model.Title + "<br/>"
                                       + "<b>Description <small>(If Any)</small>:</b> " + model.Description + "<br/>"
                                       + "<b>Tutor Information:</b> " + tutorInfo.FirstName + " " + tutorInfo.LastName + " <small>(" + tutorInfo.Gender + ")</small>, E: " + tutorInfo.Email + ", M: " + tutorInfo.PhoneNumber + "<br/>"
                                       + "<b>Communication Method:</b> " + model.CommunicationMethod + "<br/>"
                                       + "<b>Comment/Concerns <small>(If Any)</small>:</b> " + model.Concerns
                                       + "<h4>AVAILABLE ON : </h4>" + sessionInfo + "<br/><br/>"
                                       + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> Team @" + DateTime.Now.Year;

                        await EmailSender.SendEmailAsync(_subject, _body);

                        await SMSSender.SMSSenderAsync(message + " Student name is " + model.User.FirstName + " " + model.User.LastName);
                    }
                    catch (Exception ex1)
                    {
                    }
                    //});

                    ModelState.Clear();
                    ViewBag.success = "<ul><li><p style='color:green'>Hurray!! Session info successfully submitted.</p></li></ul>";
                    return(View(model));
                }
                catch (Exception ex)
                {
                    ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + ex.Message + "</p></li></ul>";
                    return(View(model));
                }
            }
            return(View(model));
        }
Beispiel #6
0
        public async Task <ScheduleModel> SaveAsync([FromBody] ScheduleCreateModel model)
        {
            var entity = await _service.CreateScheduleAsync(model.Title, model.StartDate);

            return(_mapper.Map <ScheduleModel>(entity));
        }