Ejemplo n.º 1
0
        public async Task <IActionResult> CreateClass([FromBody] ClassroomVM classroomVM)
        {
            try
            {
                var semesters = await this.timeEnrollmentRepository.GetAll().OrderByDescending(t => t.Semester).FirstOrDefaultAsync();

                var newClass = new Classroom();
                newClass.Code       = classroomVM.Code;
                newClass.Semester   = semesters.Semester;
                newClass.MaxStudent = classroomVM.MaxStudent;
                newClass.CourseId   = classroomVM.CourseId;
                newClass.TeacherId  = classroomVM.TeacherId;
                newClass.TimeSlots  = new List <TimeSlot>();
                foreach (var timeslot in classroomVM.TimeSlots)
                {
                    newClass.TimeSlots.Add(new TimeSlot {
                        Day = timeslot.Day, StartTime = timeslot.StartTime, EndTime = timeslot.EndTime, Room = timeslot.Room
                    });
                }

                this.classroomRepository.Insert(newClass);
                await this.classroomRepository.SaveChangeAsync();

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public ActionResult Update(ClassroomVM data)
        {
            Classroom cls = clsRepo.GetById(data.ID);

            cls.Name        = data.Name;
            cls.TrainerID   = data.TrainerID;
            cls.CreatedDate = data.CreatedDate;
            cls.ClosedDate  = data.ClosedDate;
            clsRepo.Edit(cls);
            return(RedirectToAction("ClassroomList", "Classroom"));
        }
Ejemplo n.º 3
0
        public ActionResult Update(int id)
        {
            TempData["trainer"] = trnRepo.GetAll();
            Classroom   cls   = clsRepo.GetById(id);
            ClassroomVM model = new ClassroomVM {
                Name        = cls.Name,
                ClosedDate  = (DateTime)cls.ClosedDate,
                CreatedDate = (DateTime)cls.CreatedDate,
                ID          = cls.Id
            };

            return(View(model));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Classrooms()
        {
            CreateBreadCrumb(new[] { new { Name = "Home", ActionUrl = "#" },
                                     new { Name = "Classroom", ActionUrl = "/Classroom/Classrooms" } });

            BaseViewModel VModel = null;

            var result = await _ClassroomService.GetAllClassrooms(500, GetBaseService().GetAppRootPath()).ConfigureAwait(false);

            var TempVModel = new ClassroomVM();

            TempVModel.ClassroomInfo      = new AppGridModel <ClassroomBM>();
            TempVModel.ClassroomInfo.Rows = result;

            VModel = await GetViewModel(TempVModel);

            return(View("~/Views/Master/Classrooms.cshtml", VModel));
        }