示例#1
0
 public long?Save(TransferSchemaDto transferSchema)
 {
     if (transferSchema != null)
     {
         using (var context = new CashFlowContext())
         {
             if (transferSchema.Id.HasValue)
             {
                 context.TransferSchema.Update(TransferSchemaMapper.Map(transferSchema));
             }
             else
             {
                 TransferSchema transferSchemaMapped = TransferSchemaMapper.Map(transferSchema);
                 context.TransferSchema.Add(transferSchemaMapped);
                 transferSchema.Id = transferSchemaMapped.Id;
             }
             context.SaveChanges();
         }
         return(transferSchema.Id);
     }
     else
     {
         return(null);
     }
 }
示例#2
0
 public TransferSchemaDto GetById(long id)
 {
     using (var context = new CashFlowContext())
     {
         DataAccess.EF.TransferSchema efTransferSchema = context.TransferSchema.SingleOrDefault(t => t.Id == id);
         if (efTransferSchema != null)
         {
             TransferSchemaDto transferSchema = TransferSchemaMapper.Map(efTransferSchema);
             return(transferSchema);
         }
         else
         {
             return(null);
         }
     }
 }
示例#3
0
 public List <TransferSchemaDto> GetAll()
 {
     using (var context = new CashFlowContext())
     {
         List <TransferSchemaDto> transferSchemas = context.TransferSchema.AsEnumerable().Select <DataAccess.EF.TransferSchema, TransferSchemaDto>(t => TransferSchemaMapper.Map(t)).ToList();
         return(transferSchemas);
     }
 }