Skip to content

Commit a52bb09

Browse files
committed
Role and Memebership work + library for implementation
1 parent cf55b90 commit a52bb09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+868
-57922
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Linq;
2+
using BookStore.DAL.Abstract;
3+
using BookStore.DLL.Abstract;
4+
using BookStore.DO.Entities;
5+
6+
namespace BookStore.BLL.RepositoryService
7+
{
8+
public class AuthorService:StoreService<Author>,IAuthorService
9+
{
10+
private readonly IAuthorRepository _repository;
11+
public AuthorService(IAuthorRepository repo)
12+
{
13+
_repository = repo;
14+
}
15+
16+
public Author GetByName(string lastName, string firstName)
17+
{
18+
return _repository.GetByName(lastName, firstName);
19+
}
20+
public override IQueryable<Author> GetAll()
21+
{
22+
return _repository.GetAll().OrderByDescending(t=>t.Rating);
23+
}
24+
25+
26+
public void AddBook(Book book, Author toAuthor)
27+
{
28+
_repository.AddBook(book, toAuthor);
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Linq;
3+
using BookStore.DAL.Abstract;
4+
using BookStore.DLL.Abstract;
5+
using BookStore.DO.Entities;
6+
7+
namespace BookStore.BLL.RepositoryService
8+
{
9+
10+
public class BookService : StoreService<Book>, IBookService
11+
{
12+
private readonly IBookRepository _repository;
13+
public BookService(IBookRepository repo)
14+
{
15+
_repository = repo;
16+
}
17+
public IQueryable<Book> Books
18+
{
19+
get
20+
{
21+
return _repository.GetAll().OrderByDescending(b => b.Rating);
22+
}
23+
}
24+
25+
public IQueryable<Book> GetBooksByLetter(string letter)
26+
{
27+
return _repository.GetBooksByLetter(letter).OrderByDescending(b => b.Rating);
28+
}
29+
30+
public IQueryable<Book> GetBooksByAuthor(string lastName)
31+
{
32+
throw new NotImplementedException();
33+
}
34+
35+
public IQueryable<Book> GetBooksByGenre(string genre)
36+
{
37+
return _repository.GetBooksByGenre(genre).OrderByDescending(b => b.Rating);
38+
}
39+
40+
public IQueryable<Book> GetBooksByTitle(string title)
41+
{
42+
throw new NotImplementedException();
43+
}
44+
45+
public IQueryable<Book> GetBooksByTag(int tagId)
46+
{
47+
return _repository.GetBooksByTag(tagId).OrderByDescending(b => b.Rating);
48+
}
49+
50+
public IQueryable<Comment> GetComment(Comment comment)
51+
{
52+
throw new NotImplementedException();
53+
}
54+
55+
public override Book GetById(int id)
56+
{
57+
return _repository.GetById(id);
58+
}
59+
60+
public override IQueryable<Book> GetAll()
61+
{
62+
return _repository.GetAll().OrderByDescending(b => b.Rating);
63+
}
64+
public override void Save(Book obj){
65+
_repository.Save(obj);
66+
}
67+
public override void Create(Book obj)
68+
{
69+
_repository.Create(obj);
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Linq;
2+
using BookStore.DAL.Abstract;
3+
using BookStore.DLL.Abstract;
4+
using BookStore.DO.Entities;
5+
6+
namespace BookStore.BLL.RepositoryService
7+
{
8+
public class GenreService:StoreService<Genre>,IGenreService
9+
{
10+
private readonly IGenreRepository _genreRepository;
11+
private Genre _genre = new Genre();
12+
public GenreService(IGenreRepository repository)
13+
{
14+
_genreRepository = repository;
15+
}
16+
17+
public IQueryable<Genre> Genres
18+
{
19+
get
20+
{
21+
return _genreRepository.GetAll();
22+
}
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("BookStore.BLL.RepositoryService")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("BookStore.BLL.RepositoryService")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4f81ff3d-330d-482b-a99b-94c225b770e0")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using BookStore.DAL.Abstract;
2+
using BookStore.DLL.Abstract;
3+
using BookStore.DO.Entities;
4+
5+
namespace BookStore.BLL.RepositoryService
6+
{
7+
public class RoleService:StoreService<Role>,IRoleService
8+
{
9+
private readonly IRoleRepository _repository;
10+
public RoleService(IRoleRepository repo)
11+
{
12+
_repository = repo;
13+
}
14+
15+
public Role GetRoleByName(string roleName)
16+
{
17+
return _repository.GetRoleByName(roleName);
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Linq;
3+
using BookStore.DAL.Abstract;
4+
using BookStore.DLL.Abstract;
5+
6+
namespace BookStore.BLL.RepositoryService
7+
{
8+
9+
public class StoreService<T> : IStoreService<T>
10+
{
11+
private readonly IStoreRepository<T> _repository;
12+
public StoreService()
13+
{
14+
15+
}
16+
public StoreService(IStoreRepository<T> repo)
17+
{
18+
_repository = repo;
19+
}
20+
21+
public virtual T GetById(int id)
22+
{
23+
return _repository.GetById(id);
24+
}
25+
26+
public virtual IQueryable<T> GetAll()
27+
{
28+
throw new NotImplementedException();
29+
}
30+
31+
32+
public virtual void Save(T obj)
33+
{
34+
_repository.Save(obj);
35+
}
36+
37+
public virtual T Delete(int id)
38+
{
39+
return _repository.Delete(id);
40+
}
41+
public virtual void Create(T obj)
42+
{
43+
_repository.Create(obj);
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using BookStore.DAL.Abstract;
5+
using BookStore.DLL.Abstract;
6+
using BookStore.DO.Entities;
7+
using Ninject;
8+
9+
namespace BookStore.BLL.RepositoryService
10+
{
11+
public class UserService:StoreService<User>,IUserService
12+
{
13+
[Inject] readonly IUserRepository _repository;
14+
public UserService(IUserRepository repo)
15+
{
16+
_repository = repo;
17+
}
18+
19+
public IQueryable<Book> GetReccomendedBooks(int userId)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
24+
public IQueryable<Book> GetWishedBooks(int userId)
25+
{
26+
throw new NotImplementedException();
27+
}
28+
29+
public IQueryable<Book> GetRatedBooks(int userId)
30+
{
31+
throw new NotImplementedException();
32+
}
33+
34+
public IQueryable<Author> GetFavAuthors(int userId)
35+
{
36+
throw new NotImplementedException();
37+
}
38+
39+
public ICollection<Role> GetRoles(int userId)
40+
{
41+
return _repository.GetRoles(userId);
42+
}
43+
44+
public IQueryable<Comment> GetComment(int userId)
45+
{
46+
throw new NotImplementedException();
47+
}
48+
49+
public void RateBook(Book book)
50+
{
51+
throw new NotImplementedException();
52+
}
53+
54+
public void WishBook(Book book)
55+
{
56+
throw new NotImplementedException();
57+
}
58+
59+
public void AddComment(Book book)
60+
{
61+
throw new NotImplementedException();
62+
}
63+
64+
public void LikeAuthor(Author author)
65+
{
66+
throw new NotImplementedException();
67+
}
68+
69+
70+
public User GetUserByEmail(string email)
71+
{
72+
return _repository.GetUserByEmail(email);
73+
}
74+
75+
public override void Create(User obj)
76+
{
77+
_repository.Create(obj) ;
78+
}
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Linq;
2+
using BookStore.DAL.Abstract;
3+
using BookStore.DO.Entities;
4+
using System.Data.Entity;
5+
6+
7+
namespace BookStore.DAL.EntityFramework
8+
{
9+
public class EfAuthorRepository:EfStoreRepository<Author>,IAuthorRepository
10+
{
11+
public Author GetByName(string lastName, string firstName)
12+
{
13+
return Context.Authors.FirstOrDefault(a => a.First_Name == firstName && a.Last_Name == lastName);
14+
}
15+
public override IQueryable<Author> GetAll()
16+
{
17+
return Context.Authors.Include(b=>b.Books);
18+
}
19+
public void AddBook(Book book, Author toAuthor)
20+
{
21+
toAuthor.Books.Add(book);
22+
Context.SaveChanges();
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)