public override void SetUp()
        {
            base.SetUp();

            TeachersRepository.Add(Arg.Any <Teacher>()).Returns(new VoidResult());
            CoursesRepository.Add(Arg.Any <Course>()).Returns(new VoidResult())
            .AndDoes(ci => _course = ci.ArgAt <Course>(0));
        }
Ejemplo n.º 2
0
        public void AddCourses(Courses entity)
        {
            CoursesRepository     courseRepository      = new CoursesRepository();
            DepartmentsRepository departmentsRepository = new DepartmentsRepository();
            Departments           departments           = departmentsRepository.PrintOne(entity.DepartmentID);

            entity.Departments = departments;
            courseRepository.Add(entity);
        }
        public ActionResult Create([Bind(Include = "CourseId,Name,TeacherId,Duration,Credits")] CourseVM coursVM)
        {
            if (ModelState.IsValid)
            {
                Cours course = CourseMap.CourseVMToCourse(coursVM);

                coursesRepo.Add(course);

                return(RedirectToAction("Index"));
            }

            coursVM.TeacherIdSelectList = SelectListHelper.CreateSelectListProp(SelectListHelper.PopulateTeacherSelectList(), coursVM.TeacherId);

            return(View(coursVM));
        }
Ejemplo n.º 4
0
 public ActionResult Create(string tID, string sID)
 {
     sID = sID.Substring(sID.IndexOf(':') + 1);
     try
     {
         int  sId     = int.Parse(sID);
         bool success = cRepo.Add(new Course
         {
             SubjectID = sId,
             TeacherID = tID
         });
         if (success)
         {
             return(RedirectToAction("Index"));
         }
         ViewBag.EMessage = "The Course You want to add already exists";
         return(View());
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 5
0
 public void Create(Courses obj)
 {
     courseRepository.Add(obj);
 }
Ejemplo n.º 6
0
 // POST api/Courses
 public IHttpActionResult Post([FromBody] Course value)
 {
     coursesRepository.Add(value);
     data.SaveChanges();
     return(this.CreatedAtRoute("Courses", "api/Courses", value));
 }