public T ConvertDBLookUpToModelLookUp <T, U>(int id, string propertyName, MagicBooksDBEntities context) where T : IDBLookup, new() where U : class, IDBLookup { var book = context.Books.Where(b => b.Id == id).FirstOrDefault(); PropertyInfo propertyInfo = book.GetType().GetProperty(propertyName); if (propertyInfo != null) { try { var lookUpProperty = propertyInfo.GetValue(book, null) as U; return(new T { Id = lookUpProperty.Id, Name = lookUpProperty.Name }); } catch (Exception) { } } return(default(T)); }
public DeliveryRepository() { context = new MagicBooksDBEntities(); }
public BookRepository() { context = new MagicBooksDBEntities(); }
public PaymentRepository() { context = new MagicBooksDBEntities(); }
public OrderRepository() { context = new MagicBooksDBEntities(); }