Ejemplo n.º 1
0
 public IEnumerable <MilkCollectionModel> GetAllRecordsByDate(DateTime date, string criteria)
 {
     try
     {
         using (var uow = new UnitOfWork(new DataContext()))
         {
             var milkProducts = new List <MilkCollectionModel>();
             var objs         = uow.MilkCollections.GetAllRecords(date, criteria);
             foreach (var item in objs)
             {
                 var model = new MilkCollectionModel();
                 model.ID         = item.MilkCollectionID;
                 model.ActualDate = item.ActualDate;
                 model.MilkClass  = item.SupplyType.Description;
                 model.MilkCost   = item.SupplyType.UnitPrice;
                 model.FullName   = item.Farmer.FullName;
                 model.Volume     = item.Volume;
                 model.Amount     = item.Volume * model.MilkCost;
                 milkProducts.Add(model);
             }
             return(milkProducts);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 public MilkCollectionModel Get(int id)
 {
     try
     {
         using (var uow = new UnitOfWork(new DataContext()))
         {
             var model = new MilkCollectionModel();
             var obj   = uow.MilkCollections.GetMilkCollection(id);
             model.ActualDate = obj.ActualDate;
             model.FullName   = obj.Farmer.FullName;
             model.MilkClass  = obj.SupplyType.Description;
             model.Volume     = obj.Volume;
             return(model);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }