コード例 #1
0
 public void DeleteNutritionGoal(NutritionGoal goal)
 {
     using (var conn = CreateConnection())
         using (var tran = conn.BeginTransaction())
         {
             try
             {
                 conn.Execute("UPDATE NutritionGoal SET Deleted=@Deleted WHERE Id=@Id", new { goal.Id, Deleted = DateTimeOffset.Now }, tran);
                 tran.Commit();
             }
             catch
             {
                 tran.Rollback();
                 throw;
             }
         }
 }
コード例 #2
0
 public void ActivateNutritionGoal(NutritionGoal goal)
 {
     using (var conn = CreateConnection())
         using (var tran = conn.BeginTransaction())
         {
             try
             {
                 conn.Execute("UPDATE NutritionGoal SET Active=0 WHERE UserId=@UserId", new { goal.UserId }, tran);
                 conn.Execute("UPDATE NutritionGoal SET Active=1 WHERE Id=@Id", new { goal.Id }, tran);
                 tran.Commit();
             }
             catch
             {
                 tran.Rollback();
                 throw;
             }
         }
 }