Beispiel #1
0
        public async Task <bool> Add(Video entity)
        {
            Video video = _dbContext.Videos.FirstOrDefault(x => x.IdVideo == entity.IdVideo);

            if (video == null)
            {
                _dbContext.Videos.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #2
0
        public async Task <bool> Add(Course entity)
        {
            Course course = _dbContext.Courses.FirstOrDefault(x => x.IdCourse == entity.IdCourse);

            if (course == null)
            {
                _dbContext.Courses.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #3
0
        public async Task <bool> Add(User entity)
        {
            User user = _dbContext.Users.FirstOrDefault(x => x.IdUser == entity.IdUser ||
                                                        x.Login.Equals(entity.Login));

            if (user == null)
            {
                _dbContext.Users.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #4
0
        public async Task <bool> Add(Tag entity)
        {
            Tag tag = _dbContext.Tags.FirstOrDefault(x => x.IdTag == entity.IdTag ||
                                                     x.Name.Equals(entity.Name));

            if (tag == null)
            {
                _dbContext.Tags.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #5
0
        public async Task <bool> Add(Category entity)
        {
            Category category = _dbContext.Categories.FirstOrDefault(x => x.IdCategory == entity.IdCategory ||
                                                                     x.CategoryName.Equals(entity.CategoryName));

            if (category == null)
            {
                _dbContext.Categories.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #6
0
        public async Task <bool> Add(Access entity)
        {
            Access access = _dbContext.Accesses.FirstOrDefault(x => x.IdUser == entity.IdUser &&
                                                               x.IdCourse == entity.IdCourse);

            if (access == null)
            {
                _dbContext.Accesses.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
Beispiel #7
0
        public async Task <bool> Add(Raiting entity)
        {
            Raiting raiting = _dbContext.Ratings.FirstOrDefault(x => x.IdUser == entity.IdUser &&
                                                                x.IdCourse == entity.IdCourse);

            if (raiting == null)
            {
                _dbContext.Ratings.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }
        public async Task <bool> Add(AccessCode entity)
        {
            AccessCode access = _dbContext.AccessCodes.FirstOrDefault(x => x.IdCode == entity.IdCode ||
                                                                      (x.IdCourse == entity.IdCourse &&
                                                                       x.Key.Equals(entity.Key)));

            if (access == null)
            {
                _dbContext.AccessCodes.Add(entity);
            }

            return(await _dbContext.SaveChangesAsync() >= 1);
        }