Exemplo n.º 1
0
 public void UpdateEnergyExpenditure(EnergyExpenditure expenditure)
 {
     using (var conn = CreateConnection())
         using (var tran = conn.BeginTransaction())
         {
             try
             {
                 conn.Execute("UPDATE EnergyExpenditure SET Time=@Time,ActivityId=@ActivityId,Duration=@Duration,ActivityName=@ActivityName,EnergyKcal=@EnergyKcal WHERE Id=@Id", expenditure, tran);
                 tran.Commit();
             }
             catch
             {
                 tran.Rollback();
                 throw;
             }
         }
 }
Exemplo n.º 2
0
 public void DeleteEnergyExpenditure(EnergyExpenditure expenditure)
 {
     using (var conn = CreateConnection())
         using (var tran = conn.BeginTransaction())
         {
             try
             {
                 conn.Execute("UPDATE EnergyExpenditure SET Deleted=@Deleted WHERE Id=@Id", new { expenditure.Id, Deleted = DateTimeOffset.Now }, tran);
                 tran.Commit();
             }
             catch
             {
                 tran.Rollback();
                 throw;
             }
         }
 }
Exemplo n.º 3
0
 public void CreateEnergyExpenditure(EnergyExpenditure expenditure)
 {
     expenditure.Id      = Guid.NewGuid();
     expenditure.Created = DateTimeOffset.Now;
     using (var conn = CreateConnection())
         using (var tran = conn.BeginTransaction())
         {
             try
             {
                 conn.Execute("INSERT INTO EnergyExpenditure(Id,UserId,Time,ActivityId,Duration,ActivityName,EnergyKcal,WorkoutId,Created) VALUES(@Id,@UserId,@Time,@ActivityId,@Duration,@ActivityName,@EnergyKcal,@WorkoutId,@Created)", expenditure, tran);
                 tran.Commit();
             }
             catch
             {
                 tran.Rollback();
                 expenditure.Id = Guid.Empty;
                 throw;
             }
         }
 }