Пример #1
0
        public ActionResult Content(ContentViewModel contentVM)
        {
            var comment   = contentVM.Subscription.Comment;
            var rating    = contentVM.Subscription.Rate;
            var courseId  = contentVM.Course.Id;
            int accountId = ((Account)Session[UserType.LoggedInUser.ToString()]).Id;


            if (!String.IsNullOrEmpty(comment) && rating != null)
            {
                ElearnerDataLayoutActions.SaveSubscriptionChanges(courseId, accountId, comment, rating);
                TempData["Comment"] = true;
                TempData["Rating"]  = true;
            }
            else if (!String.IsNullOrEmpty(comment))
            {
                ElearnerDataLayoutActions.SaveSubscriptionChanges(courseId, accountId, comment, rating);
                TempData["Comment"] = true;
                TempData["Rating"]  = false;
            }
            else if (rating != null)
            {
                ElearnerDataLayoutActions.SaveSubscriptionChanges(courseId, accountId, comment, rating);
                TempData["Comment"] = false;
                TempData["Rating"]  = true;
            }
            else
            {
                TempData["Comment"] = false;
                TempData["Rating"]  = false;
            }


            return(RedirectToAction("Content", "Courses", new { id = courseId }));
        }
Пример #2
0
        public ActionResult Content(int id)
        {
            if (Session[UserType.LoggedInUser.ToString()] == null)
            {
                ViewData["LogInFirst"] = true;
                return(RedirectToAction("LogIn", "Authedication"));
            }

            ViewData["LogInFirst"] = false;

            if (TempData["Comment"] != null || TempData["Rating"] != null)
            {
                ViewBag.Comment = (bool)TempData["Comment"];
                ViewBag.Rating  = (bool)TempData["Rating"];
            }


            Course result = ElearnerDataLayoutActions.GetContent(id);

            var contentVM = new ContentViewModel
            {
                Course       = result,
                Content      = result.Content,
                Subscription = new Subscription()
            };

            return(View(contentVM));
        }
Пример #3
0
        public ActionResult Purchase(Course current)
        {
            ViewData["LogInFirst"] = false;

            if (Session[UserType.LoggedInUser.ToString()] == null)
            {
                ViewData["LogInFirst"] = true;
                return(RedirectToAction("LogIn", "Authedication"));
            }

            PurchaseViewModel purchaseViewModel = new PurchaseViewModel();
            Account           logInUser         = (Account)Session[UserType.LoggedInUser.ToString()];

            if (logInUser == null)
            {
                purchaseViewModel.ResultMessase = "You must Sign Up First!";
                return(View(purchaseViewModel));
            }

            purchaseViewModel.ResultMessase = ElearnerDataLayoutActions.PurchaseCourse(current.Id, logInUser.Id, current.Price);

            if (purchaseViewModel.ResultMessase == "Course is free")
            {
                return(RedirectToAction("Content", new { Id = current.Id }));
            }

            purchaseViewModel.SelectedCourse = current;
            logInUser.BankAccount.Deposit    = ElearnerDataLayoutActions.UpdateUserDeposit(logInUser.Id);

            return(View(purchaseViewModel));
        }
Пример #4
0
        public ActionResult Subscriptions(int id)
        {
            if (Session[UserType.LoggedInUser.ToString()] == null)
            {
                return(RedirectToAction("Index"));
            }
            IList <Subscription> subscriptions = ElearnerDataLayoutActions.GetStudentSubscriptions(id);

            return(View(subscriptions));
        }
Пример #5
0
        public ActionResult TeacherProfile(int id)
        {
            if (Session[UserType.LoggedInUser.ToString()] == null)
            {
                return(RedirectToAction("Index"));
            }

            IList <Course> teacherCourses = ElearnerDataLayoutActions.GetCourseByTeacher(id);

            return(View(teacherCourses));
        }
Пример #6
0
        public IHttpActionResult Comment(Course course)
        {
            int bl = 0;

            if (course.Name == ElearnerDataLayoutActions.GetCourseFromDb(3, null).Name)
            {
                bl = 1;
            }


            return(Ok(course));
        }
Пример #7
0
        public ActionResult EditCourse(int id)
        {
            if (Session[UserType.LoggedInUser.ToString()] != null && ((Account)Session[UserType.LoggedInUser.ToString()]).Teacher != null)
            {
                Course teachersCourse = ElearnerDataLayoutActions.GetFullCourseDetails(id);

                return(View(teachersCourse));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #8
0
        public ActionResult AddMoneyToStudent(AddMoneyViewModel addMoneyViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddMoney"));
            }

            Account currentUser = (Account)Session[UserType.LoggedInUser.ToString()];

            currentUser.BankAccount.Deposit = ElearnerDataLayoutActions.AddMoneyToUser(currentUser.Id, addMoneyViewModel.Amount);

            return(View("Index"));
        }
Пример #9
0
        public ActionResult SearchResult(SearchViewModel vm)
        {
            vm.SearchResults = new List <Course>();

            if (!ModelState.IsValid || vm.Search() == null)
            {
                TempData["InvalidSearchMessage"] = "Invalid Search";
                return(RedirectToAction("Index"));
            }

            foreach (var item in vm.Search())
            {
                vm.SearchResults.Add(ElearnerDataLayoutActions.GetCourseFromDb(item.Id, null));
            }

            return(View(vm));
        }
        public ActionResult SignUpStudent(SignUpViewModel sendedModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("SignUpForm"));
            }

            Account result = ElearnerDataLayoutActions.SignUp(sendedModel.UserPersonalInfo.Name, sendedModel.UserPersonalInfo.Lastname,
                                                              sendedModel.UserPersonalInfo.Birthdate, sendedModel.UserAccount.Email,
                                                              sendedModel.UserAccount.Password, sendedModel.UserBankAccount.Deposit);

            if (result == null)
            {
                return(View("SignUpForm"));
            }

            Session[UserType.LoggedInUser.ToString()] = result;
            return(View("SuccessfulSignUp"));
        }
Пример #11
0
        public ActionResult QuizResults(QuizViewModel vm)
        {
            QuizViewModel oldviewModel = (QuizViewModel)TempData["FullModel"];
            QuizViewModel newViewModel = oldviewModel;

            newViewModel.QuizResults = new List <bool>();
            Account logInUser = (Account)Session[UserType.LoggedInUser.ToString()];

            for (int i = 0; i < oldviewModel.Questions.Count; i++)
            {
                newViewModel.QuizResults.Add((oldviewModel.Questions[i].Answer == vm.UserAnswers[i]) ? true : false);
            }

            byte?grade = (byte)newViewModel.QuizResults.Where(x => x == true).Count();

            ElearnerDataLayoutActions.UpdateGradeToDb(grade, logInUser.Id, oldviewModel.Course.Id);

            return(View(newViewModel));
        }
Пример #12
0
        public IHttpActionResult Comment()
        {
            List <Course> list = new List <Course>
            {
                ElearnerDataLayoutActions.GetCourseFromDb(2, null),
                ElearnerDataLayoutActions.GetCourseFromDb(3, null),
                ElearnerDataLayoutActions.GetCourseFromDb(4, null),
                ElearnerDataLayoutActions.GetCourseFromDb(5, null),
                ElearnerDataLayoutActions.GetCourseFromDb(6, null)
            };


            List <Course> list2 = new List <Course>();

            list2.Add(new Course {
                Name = list[0].Name, Id = list[0].Id, Duration = list[0].Duration, Price = list[0].Price, TeacherId = list[0].TeacherId, Description = list[0].Description
            });

            return(Ok(list2));
        }
        public ActionResult SignUpTeacher(SignUpTeacherViewModel teacherViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("SignUpTeacherForm"));
            }

            teacherViewModel.AddQuestions();
            Account result = ElearnerDataLayoutActions.SignUpTeacher(teacherViewModel);

            if (teacherViewModel.Image.ContentLength > 0)
            {
                var fileName = Path.GetFileName(teacherViewModel.Image.FileName);
                var path     = Path.Combine(Server.MapPath("~/Content/images"), Utilities.FileTools.RemoveSpacesFromFilename(teacherViewModel.TeachingCourse.Name) + ".png");
                teacherViewModel.Image.SaveAs(path);
            }

            Session[UserType.LoggedInUser.ToString()] = result;
            return(View("SuccessfulSignUpTeacher"));
        }
Пример #14
0
        public ActionResult AddCourseToDb(AddCourseViewModel addCourseViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddCourse"));
            }

            Account currentUser = (Account)Session[UserType.LoggedInUser.ToString()];

            addCourseViewModel.AddQuestions();
            ElearnerDataLayoutActions.AddCourseToDb(currentUser, addCourseViewModel);

            if (addCourseViewModel.Image.ContentLength > 0)
            {
                var fileName = Path.GetFileName(addCourseViewModel.Image.FileName);
                var path     = Path.Combine(Server.MapPath("~/Content/images"), Utilities.FileTools.RemoveSpacesFromFilename(addCourseViewModel.TeachingCourse.Name) + ".png");
                addCourseViewModel.Image.SaveAs(path);
            }

            return(View("Index"));
        }
        public ActionResult Login(Account account)
        {
            if (!ModelState.IsValid)
            {
                return(View("Login"));
            }

            Account result = ElearnerDataLayoutActions.HasAccount(account.Email, account.Password);

            if (result == null)
            {
                Session["wrongAuthedication"] = true;
                return(View(account));
            }

            if (result.Password != account.Password)
            {
                ViewBag.NotMatching = true;
                return(View(account));
            }

            Session[UserType.LoggedInUser.ToString()] = result;
            return(RedirectToAction("Index", "Home"));
        }
Пример #16
0
        // GET: Courses
        public ActionResult CourseView(int id)
        {
            Course queryResult = ElearnerDataLayoutActions.GetCourseFromDb(id, null);

            return(View(queryResult));
        }
Пример #17
0
        public ActionResult Teachers()
        {
            var teacherList = ElearnerDataLayoutActions.GetTeachers();

            return(View(teacherList));
        }
Пример #18
0
        public ActionResult SaveCourseChanges(Course course)
        {
            ElearnerDataLayoutActions.UpdateCourse(course);

            return(RedirectToAction("CourseView", "Courses", new { id = course.Id }));
        }