Example #1
0
        public void Init()
        {
            // Arrange
            b1 = new Book("1");
            b2 = new Book("2", "Falling in Love with Yourself");
            b3 = new Book("3", "Spirits in the Night", 123.55);

            a1 = new Amulet("11");
            a2 = new Amulet("12", Level.high);
            a3 = new Amulet("13", Level.low, "Capricorn");

            c1 = new Course("Eufori med røg");
            c2 = new Course("Nuru Massage using Chia Oil", 157);

            courses = new CourseRepository();
            books   = new BookRepository();
            amulets = new AmuletRepository();

            // Act
            books.AddBook(b1);
            books.AddBook(b2);
            books.AddBook(b3);

            amulets.AddAmulet(a1);
            amulets.AddAmulet(a2);
            amulets.AddAmulet(a3);

            courses.AddCourse(c1);
            courses.AddCourse(c2);
        }
Example #2
0
        public async Task <IActionResult> AddCourse([FromBody] Courses model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var courseId = await course.AddCourse(model);

                    if (courseId > 0)
                    {
                        return(Ok(courseId));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Example #3
0
        protected override Task <AddCourseResponseDto> ExecuteAsync(AddCourseRequestDto request, RequestContext context)
        {
            // Get course information
            var name         = request.CourseName;
            var code         = request.CourseCode;
            var studyGroupId = request.StudyGroupId;

            // Get study group with university
            var faculty = _uniwikiContext
                          .StudyGroups
                          .Include(g => g.University)
                          .Single(g => g.Id == request.StudyGroupId);

            // Check if the course name is unique
            if (!_courseRepository.IsNameUnique(faculty.Id, name))
            {
                throw new RequestException(_textService.Error_CourseNameTaken(name));
            }

            // Create url for the course
            var url = _stringStandardizationService.CreateUrl(name, u => _courseRepository.IsCourseUrlUnique(faculty.Id, u));

            // Create the course
            var course = _courseRepository.AddCourse(code, name, context.UserId !.Value, faculty.Id, faculty.University.Url, url, faculty.Url);

            return(Task.FromResult(new AddCourseResponseDto(course.Id, course.Url, course.Url, course.Url)));
        }
Example #4
0
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (TxbxTitle.Text != String.Empty && TxbxDescription.Text != String.Empty)
            {
                if (TxbxFilePath.Text != String.Empty)
                {
                    FileNameGuidAdd = String.Format(Guid.NewGuid() + ".zip");
                }


                Courses courses = new Courses
                {
                    UserId       = UserIdAdd,
                    Category     = SelectedCategory,
                    Title        = TxbxTitle.Text.Trim(),
                    Description  = TxbxDescription.Text.Trim(),
                    Date         = String.Format($"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"),
                    Hyperlink    = TxbxHyperlink.Text.Trim(),
                    FileNameGuid = FileNameGuidAdd
                };
                courseRepository.AddCourse(courses, TxbxTitle, TxbxDescription, TxbxHyperlink, TxbxFilePath);

                if (FileNameGuidAdd != null)
                {
                    Task task = new Task(() => courseRepository.SendFileToDb(UserIdAdd, "172.20.2.221\\", FilePath, FileNameGuidAdd));
                    task.Start();
                }
            }
            else
            {
                MessageBox.Show("Одно или несколько полей не заполнено!", "", MessageBoxButton.OK,
                                MessageBoxImage.Information);
            }
        }
Example #5
0
        public ActionResult AddCourse(Course course)
        {
            ViewBag.dl = _courseRepository.AllDepartment().ToList();
            ViewBag.sl = _courseRepository.AllSemester().ToList();
            string message = "";

            try
            {
                if (ModelState.IsValid)
                {
                    //if(course.TeacherId == 0)
                    //{
                    //    course.TeacherId = null;
                    //}
                    bool IsSaved = _courseRepository.AddCourse(course);
                    if (IsSaved)
                    {
                        message = "Course Saved Successfully";
                        //ViewBag.Sm = message;
                        TempData["Sm"] = message;
                    }
                    //ViewBag.Um = "";
                }
                //ViewBag.Um = Utility.GetModelStateError(ModelState);
                TempData["Em"] = Utility.GetModelStateError(ModelState);
                //return View();
                return(RedirectToAction("AddCourse"));
            }
            catch (Exception exception)
            {
                message        = exception.Message;
                TempData["Em"] = message;
                return(RedirectToAction("AddCourse"));
            }
        }
Example #6
0
        public ViewResult addCourseForm(Course courseAdded)
        {
            CourseRepository repository = new CourseRepository();

            repository.AddCourse(courseAdded.CourseName, courseAdded.CourseId, courseAdded.Syllabus, courseAdded.AnnouncementId);

            return(View("courseAdded", courseAdded));
        }
Example #7
0
        public void Init()
        {
            b1 = new Book("1");
            b2 = new Book("2", "Falling in Love with Yourself");
            b3 = new Book("3", "Spirits in the Night", 123.55);
            //merchandises.AddMerchandise(b1);
            // merchandises.AddMerchandise(b2);
            // merchandises.AddMerchandise(b3);

            a11 = new Amulet("11");
            a12 = new Amulet("12", Level.high);
            a13 = new Amulet("13", Level.low, "Capricorn");
            // merchandises.AddMerchandise(a11);
            // merchandises.AddMerchandise(a12);
            // merchandises.AddMerchandise(a13);

            c111 = new Course("Eufori med røg");
            c112 = new Course("Nuru Massage using Chia Oil", 157);
            courses.AddCourse(c111);
            courses.AddCourse(c112);
        }
        public ActionResult AddCourse(string name, string description, List <int> modules, List <int> packages)
        {
            string            message  = string.Empty;
            bool              errored  = false;
            CourseRepository  repo     = new CourseRepository();
            PackageRepository pckgRepo = new PackageRepository();

            if (string.IsNullOrEmpty(name))
            {
                errored = true;
                message = "Missing value";
            }
            else
            {
                try
                {
                    int newCourseID = repo.AddCourse(name);
                    if (modules != null && modules.Count > 0)
                    {
                        repo.AddModulesToCourse(newCourseID, modules);
                    }
                    pckgRepo.AddDefaultPackage(newCourseID);
                    if (packages != null && packages.Count > 0)
                    {
                        pckgRepo.AddPackagesToCourse(newCourseID, packages);
                    }
                }
                catch (Exception exc)
                {
                    errored = true;
                    message = exc.ToString();
                }
            }

            if (!errored)
            {
                message = "Changes Saved";
            }

            return(Json(new { Errored = errored, Message = message }, JsonRequestBehavior.AllowGet));
        }
 public IActionResult Create(Course newCourse)
 {
     newCourse = _courseRepository.AddCourse(newCourse.CourseName);
     return(RedirectToAction(nameof(Index)));
 }
Example #10
0
 public void Add(Course course)
 {
     courseRepository.AddCourse(course);
 }
Example #11
0
 public void AddCourse([FromBody] Course course)
 {
     Coursecon.AddCourse(course);
 }