Example #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();
 }
 public BookRepository()
 {
     context = new MagicBooksDBEntities();
 }
Example #4
0
 public PaymentRepository()
 {
     context = new MagicBooksDBEntities();
 }
Example #5
0
 public OrderRepository()
 {
     context = new MagicBooksDBEntities();
 }