public LocalDepositForm(LocalDeposit deposit) : this() { _deposit = deposit; FormTitleLabel.Text = $"{_deposit.User.Username}' deposit"; UsernameTextBox.Text = _deposit.User.Username; TitleTextBox.Text = _deposit.Title; UpdateInfo(); }
public SerializationLocalDeposit(LocalDeposit localDeposit) { Account = localDeposit.Account; OpenDate = localDeposit.OpenDate.Json(); User = localDeposit.User.Username; ParentDeposit = localDeposit.ParentDeposit.Title; List <string> history = new List <string>(); foreach (TransferAction transferAction in localDeposit.History) { history.Add(transferAction.Json()); } History = history.ToArray(); }
static private void SaveElement(string folderPath, User user = null, Deposit deposit = null, LocalDeposit localDeposit = null) { string fileName = "unknown.json"; if (user != null) { fileName = user.Username + ".json"; } else if (deposit != null) { fileName = deposit.Title + ".json"; } else if (localDeposit != null) { int i = 0; do { fileName = localDeposit.User.Username + "." + localDeposit.Title + $".{i++}.json"; }while (File.Exists(folderPath + @"\" + fileName)); } string filePath = folderPath + @"\" + fileName; using (StreamWriter streamWriter = new StreamWriter(filePath)) { string elementJson = "<Unknown>"; if (user != null) { elementJson = user.Json(); } else if (deposit != null) { elementJson = deposit.Json(); } else if (localDeposit != null) { elementJson = localDeposit.Json(); } streamWriter.Write(elementJson); } }