Example #1
0
 public long?Save(TransferDto transfer)
 {
     if (transfer != null)
     {
         using (var context = new CashFlowContext())
         {
             if (transfer.Id.HasValue)
             {
                 context.Transfer.Update(TransferMapper.Map(transfer));
             }
             else
             {
                 Transfer transferMapped = TransferMapper.Map(transfer);
                 context.Transfer.Add(transferMapped);
                 transfer.Id = transferMapped.Id;
             }
             context.SaveChanges();
         }
         return(transfer.Id);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
 public TransferDto GetById(long id)
 {
     using (var context = new CashFlowContext())
     {
         DataAccess.EF.Transfer efTransfer = context.Transfer
                                             .Include(t => t.AccountFrom)
                                             .Include(t => t.AccountTo)
                                             .SingleOrDefault(t => t.Id == id);
         if (efTransfer != null)
         {
             TransferDto transfer = TransferMapper.Map(efTransfer);
             return(transfer);
         }
         else
         {
             return(null);
         }
     }
 }
Example #3
0
 public PagedList <TransferDto> Get(DataFilter dataFilter)
 {
     using (var context = new CashFlowContext())
     {
         PagedList <TransferDto> transfers = new PagedList <TransferDto>(context.Transfer
                                                                         .Include(t => t.AccountFrom)
                                                                         .Include(t => t.AccountTo)
                                                                         .Filter <DataAccess.EF.Transfer, TransferDto>(dataFilter)
                                                                         .AsEnumerable()
                                                                         .Select <DataAccess.EF.Transfer, TransferDto>(t => TransferMapper.Map(t))
                                                                         .ToList());
         transfers.TotalCount = context.Transfer
                                .Include(t => t.AccountFrom)
                                .Include(t => t.AccountTo).Filter <Transfer, TransferDto>(dataFilter.FilterProperties).Count();
         return(transfers);
     }
 }