Пример #1
0
        public CourseTracker AddTracker(CourseTracker tracker)
        {
            tracker.IsCompleted = false;

            if (_context.CourseTrackers.FirstOrDefault(ct => ct.CourseID == tracker.CourseID && tracker.ApplicationUserId == tracker.ApplicationUserId) == null)
            {
                var addedTracker = _context.Add(tracker);
                _context.SaveChanges();
                return(tracker);
            }

            return(null);
        }
        public CourseTracker AddTracker(CourseTracker tracker)
        {
            tracker.IsCompleted = false;

            if (_context.CourseTrackers.FirstOrDefault(ct => ct.CourseID == tracker.CourseID && tracker.ApplicationUserId == tracker.ApplicationUserId) == null)
            {
                var addedTracker = _context.Add(tracker);
                _context.SaveChanges();
                return tracker;
            }

            return null;
        }
Пример #3
0
        public CourseTracker UpdateCourseTracker(CourseTracker updatedTracker)
        {
            var tracker = _context.CourseTrackers.FirstOrDefault(ct => ct.CourseTrackerID == updatedTracker.CourseTrackerID);

            if (tracker != null)
            {
                tracker.IsCompleted = updatedTracker.IsCompleted;

                _context.Entry(tracker).SetState(Microsoft.Data.Entity.EntityState.Modified);

                _context.SaveChanges();
                return(tracker);
            }

            return(null);
        }
        public CourseTracker UpdateCourseTracker(CourseTracker updatedTracker)
        {
            var tracker = _context.CourseTrackers.FirstOrDefault(ct => ct.CourseTrackerID == updatedTracker.CourseTrackerID);

            if (tracker != null)
            {
                tracker.IsCompleted = updatedTracker.IsCompleted;

                _context.Entry(tracker).SetState(Microsoft.Data.Entity.EntityState.Modified);

                _context.SaveChanges();
                return tracker;
            }

            return null;
        }