public IList <RatingDetailModel> GetAll() { using (var dbContext = _dbContextSqlFactory.CreateDbContext()) { return(dbContext.Ratings .Select(e => RatingMapper.MapRatingEntityToDetailModel(e)) .ToList()); } }
public RatingDetailModel Create(RatingDetailModel model) { using (var dbContext = _dbContextSqlFactory.CreateDbContext()) { var entity = RatingMapper.MapRatingDetailModelToEntity(model); dbContext.Ratings.Add(entity); dbContext.SaveChanges(); return(RatingMapper.MapRatingEntityToDetailModel(entity)); } }
public IList <RatingDetailModel> GetAllByMovieId(Guid id) { using (var dbContext = _dbContextSqlFactory.CreateDbContext()) { return(dbContext.Ratings .Where(t => t.RatedMovieId == id) .Select(e => RatingMapper.MapRatingEntityToDetailModel(e)) .ToList()); } }