private void SaveJson(JsonFileViewModel model) { _receiptService.Add(new Receipt { Json = model.Json, ReceiptImageId = model.ReceiptImage.Id }); }
public async Task <ActionResult <ReceiptViewModel> > PostReceipt(ReceiptViewModel receipt, Guid userId) { if (receipt != null) { try { await Task.Run(() => { receipt.DateCreated = DateTime.Now; receipt.AppUserId = userId; _receiptService.Add(receipt); _receiptService.SaveChanges(); return(Ok("Thêm phiếu thu thành công!")); }); } catch { throw new Exception(string.Format("Lỗi khi thêm dữ liệu")); } } return(CreatedAtAction("GetReceipt()", new { id = receipt.Id }, receipt)); }
private void Button_Click(object sender, RoutedEventArgs e) { if (Convert.ToInt32(CountInput.Text) > 0 && Convert.ToInt32(PriceInput.Text) > 0 && !string.IsNullOrEmpty(NameInput.Text)) { var receipt = new Receipt { FirstName = NameInput.Text, LastName = NameInput.Text, OperationType = _type, ClientMoney = Convert.ToDouble(PriceInput.Text), OfficeMoney = Convert.ToDouble(CountInput.Text), DateTime = DateTime.Now, CurrencyType = (CurrencyType)CurrencyTypeComboBox.SelectedItem }; _receiptService.Add(receipt); this.Close(); } else { MessageBox.Show(this, $"Something goes wrong.", "Error", MessageBoxButton.OK); } }