public async Task <ActionResult <MoneyCategory> > PostMoneyCategory(MoneyCategory moneyCategory) { _context.MoneyCategories.Add(moneyCategory); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMoneyCategory", new { id = moneyCategory.ID }, moneyCategory)); }
public async Task <IActionResult> PutMoneyCategory(long id, MoneyCategory moneyCategory) { if (id != moneyCategory.ID) { return(BadRequest()); } _context.Entry(moneyCategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MoneyCategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Money(MoneyCategory moneyCategory, double amount) { Amount = amount; switch (moneyCategory) { case MoneyCategory.RMB: this.moneyCategory = MoneyCategory.RMB; break; case MoneyCategory.USD: this.moneyCategory = MoneyCategory.USD; break; case MoneyCategory.JPY: this.moneyCategory = MoneyCategory.JPY; break; case MoneyCategory.EUR: this.moneyCategory = MoneyCategory.EUR; break; case MoneyCategory.GBP: this.moneyCategory = MoneyCategory.GBP; break; default: Console.WriteLine("Haven't input the money category."); break; } }
public static HtmlString DisplayCategoryColor(this HtmlHelper htmlHelper, MoneyCategory moneyCategory) { string className = ""; if (moneyCategory == MoneyCategory.支出) { className = "danger"; } else if (moneyCategory == MoneyCategory.收入) { className = "success"; } return(new MvcHtmlString($"class={className}")); }
private void AddButton_Click(object sender, EventArgs e) { if (!File.Exists(Path.Text)) { Account newAccount = new Account(); SaveAccount(newAccount, Path.Text); } Account account = OpenAccount(Path.Text); Category selectedCategory = (Category)Enum.Parse(typeof(Category), categoryBox.SelectedItem.ToString()); MoneyCategory selectedMoneyCategory = (MoneyCategory)Enum.Parse(typeof(MoneyCategory), moneyCategoryBox.SelectedItem.ToString()); Money money = new Money(selectedMoneyCategory, Convert.ToDouble(MoneyInput.Text)); AccountItem item = new AccountItem(NameInput.Text, selectedCategory, money, dateTimePicker1.Value, ContentInput.Text, NoteInput.Text); account.Add(item); SaveAccount(account, Path.Text); }