Beispiel #1
0
        public async Task <ClassRoutine> UpdateClassRoutine(int id, ClassRoutine classRoutine)
        {
            ClassRoutine clr = _context.ClassRoutine.Find(classRoutine.Id);

            if (clr != null)
            {
                //Update that educationSystem
                clr.DayOfWeek     = classRoutine.DayOfWeek;
                clr.StartTime     = classRoutine.StartTime;
                clr.EndTime       = classRoutine.EndTime;
                clr.PeriodNumber  = classRoutine.PeriodNumber;
                clr.ClassDuration = classRoutine.ClassDuration;
                clr.SubjectId     = classRoutine.SubjectId;
                clr.TeacherId     = classRoutine.TeacherId;
                clr.ClassRoomId   = classRoutine.ClassRoomId;

                _context.ClassRoutine.Update(clr);
            }
            try
            {
                var result = await _context.SaveChangesAsync();

                return(classRoutine);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public async Task <ClassRoutine> CreateClassRoutine(ClassRoutine classRoutine)
        {
            if (classRoutine.Id == 0)
            {
                _context.ClassRoutine.Add(classRoutine);
            }
            try
            {
                await _context.SaveChangesAsync();

                return(classRoutine);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }