Ejemplo n.º 1
0
        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();
 }
Ejemplo n.º 3
0
 public BookRepository()
 {
     context = new MagicBooksDBEntities();
 }
Ejemplo n.º 4
0
 public PaymentRepository()
 {
     context = new MagicBooksDBEntities();
 }
Ejemplo n.º 5
0
 public OrderRepository()
 {
     context = new MagicBooksDBEntities();
 }