예제 #1
0
        public void CompleteSaving(ISaving saving)
        {
            var reservations = GetReservations(saving.SavingId).ToList();
            var i            = 0;

            using (var connection = _connection.SqlConnection)
            {
                var commands = reservations.Select(reservation => new SqlCommand("INSERT INTO dbo.[Transaction] ([Name],Amount,TimeOfTransaction,AccountId,Category,IconId) VALUES('Saving Reservation',@Amount,@Time,@AccountId,'SavingPlan',@IconId)", connection)).ToList();
                foreach (var command in commands)
                {
                    command.Parameters.AddWithValue("@Amount", -reservations[i].Amount);
                    command.Parameters.AddWithValue("@Time", DateTime.Now);
                    command.Parameters.AddWithValue("@AccountId", reservations[i].AccountId);
                    command.Parameters.AddWithValue("IconId", 0);
                    i++;
                }
                connection.Open();
                foreach (var command in commands)
                {
                    command.ExecuteNonQuery();
                }
                connection.Close();
            }
            RemoveReservations(saving.SavingId);
        }
예제 #2
0
 public void UpdateSaving(ISaving saving)
 {
     using (var connection = _connection.SqlConnection)
     {
         var command = new SqlCommand("UPDATE dbo.Savings set SavingsName=@Name,CurrentAmount=@Current,GoalAmount=@Goal,IconId=@IconId,[State]=@State,GoalDate=@GoalDate WHERE SavingsId=@Id", connection);
         command.Parameters.AddWithValue("@Id", saving.SavingId);
         command.Parameters.AddWithValue("@Name", saving.SavingName);
         command.Parameters.AddWithValue("@Current", saving.SavingCurrentAmount);
         command.Parameters.AddWithValue("@Goal", saving.SavingsGoalAmount);
         command.Parameters.AddWithValue("@IconId", saving.IconId);
         command.Parameters.AddWithValue("@State", (int)saving.State);
         command.Parameters.AddWithValue("@GoalDate", saving.GoalDate);
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
     }
 }
예제 #3
0
 public void CreateSaving(ISaving saving)
 {
     using (var connection = _connection.SqlConnection)
     {
         var command = new SqlCommand("INSERT INTO dbo.Savings (UserId,SavingsName,CurrentAmount,IconId,GoalAmount,[State],DateOfCreation,GoalDate) VALUES(@UserId,@Name,@Current,@IconId,@Goal,@State,@DateOfC, @GoalDate)", connection);
         command.Parameters.AddWithValue("@Name", saving.SavingName);
         command.Parameters.AddWithValue("@Current", saving.SavingCurrentAmount);
         command.Parameters.AddWithValue("@Goal", saving.SavingsGoalAmount);
         command.Parameters.AddWithValue("@IconId", saving.IconId);
         command.Parameters.AddWithValue("@State", (int)saving.State);
         command.Parameters.AddWithValue("@GoalDate", saving.GoalDate);
         command.Parameters.AddWithValue("@UserId", saving.UserId);
         command.Parameters.AddWithValue("@DateOfC", DateTime.Now);
         connection.Open();
         command.ExecuteNonQuery();
         connection.Close();
     }
 }
예제 #4
0
 public static void AddSaving(ISaving saving)
 {
     _savers.Add(saving);
 }
예제 #5
0
 public static void RemoveSaving(ISaving saving)
 {
     _savers.Remove(saving);
 }
예제 #6
0
 public Logic(ISaving saving, ILogger <Logic> logger)
 {
     _saving = saving;
     _logger = logger;
 }
예제 #7
0
 public void CompleteSaving(ISaving saving)
 {
     _context.CompleteSaving(saving);
 }
예제 #8
0
 public void UpdateSaving(ISaving saving)
 {
     _context.UpdateSaving(saving);
 }
예제 #9
0
 public void CreateSaving(ISaving saving)
 {
     _context.CreateSaving(saving);
 }