private List <ArrearsActionDiaryEntry> InsertRandomActionDiaryDetails(string tenancyRef, int num) { List <ArrearsActionDiaryEntry> items = null; SqlCommand command = null; try { var random = new Faker(); items = new List <ArrearsActionDiaryEntry>(); string commandText = "INSERT INTO araction (tag_ref, action_code, action_type, action_date, action_comment, action_balance, " + "username) " + "VALUES (@tenancyRef, @actionCode, @actionType, @actionDate, @actionComment, @actionBalance, @uhUsername)"; foreach (int i in Enumerable.Range(0, num)) { ArrearsActionDiaryEntry arrearsActionDiaryEntry = new ArrearsActionDiaryEntry { TenancyRef = tenancyRef, Code = random.Random.Hash(3), Date = new DateTime(random.Random.Int(1900, 1999), random.Random.Int(1, 12), random.Random.Int(1, 28), 9, 30, 0), Type = random.Random.Hash(3), Comment = random.Random.Hash(50), Balance = random.Finance.Amount(), UniversalHousingUsername = random.Random.Hash(40) }; command = new SqlCommand(commandText, db); command.Parameters.Add("@tenancyRef", SqlDbType.Char); command.Parameters["@tenancyRef"].Value = arrearsActionDiaryEntry.TenancyRef; command.Parameters.Add("@actionCode", SqlDbType.Char); command.Parameters["@actionCode"].Value = arrearsActionDiaryEntry.Code; command.Parameters.Add("@actionDate", SqlDbType.SmallDateTime); command.Parameters["@actionDate"].Value = arrearsActionDiaryEntry.Date; command.Parameters.Add("@actionType", SqlDbType.Char); command.Parameters["@actionType"].Value = arrearsActionDiaryEntry.Type; command.Parameters.Add("@actionComment", SqlDbType.NVarChar); command.Parameters["@actionComment"].Value = arrearsActionDiaryEntry.Comment; command.Parameters.Add("@actionBalance", SqlDbType.Decimal); command.Parameters["@actionBalance"].Value = arrearsActionDiaryEntry.Balance; command.Parameters.Add("@uhUsername", SqlDbType.Char); command.Parameters["@uhUsername"].Value = arrearsActionDiaryEntry.UniversalHousingUsername; items.Add(arrearsActionDiaryEntry); command.ExecuteNonQuery(); } return(items.OrderByDescending(i => i.Date).ToList()); } catch (Exception ex) { throw ex; } finally { command = null; } }
public void SetActionDiaryDetails(string tenancyRef, ArrearsActionDiaryEntry actionDiary) { StoredActionDiaryDetails[tenancyRef] = actionDiary; }