From a800b3b9f18ae3e8ab030c30c5d7b6504f2a5ebb Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 1 Aug 2020 20:14:34 +0200 Subject: Initial commit --- src/server/Models/Database/Transaction.cs | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/server/Models/Database/Transaction.cs (limited to 'src/server/Models/Database/Transaction.cs') diff --git a/src/server/Models/Database/Transaction.cs b/src/server/Models/Database/Transaction.cs new file mode 100644 index 0000000..a81626b --- /dev/null +++ b/src/server/Models/Database/Transaction.cs @@ -0,0 +1,43 @@ +using System; +using Dough.Models.Exceptions; + +namespace Dough.Models.Database +{ + public class Transaction : BaseModel + { + public string Tags { get; set; } + public string Note { get; set; } + public DateTime Date { get; set; } + public double Amount { get; set; } + public Guid PayeeId { get; set; } + public Guid CategoryId { get; set; } + + public void Validate() + { + if (PayeeId == default) + { + var validationException = new ModelValidationException("PayeeId is invalid"); + validationException.ErrorResult.Title = "Mottaker er ugyldig"; + throw validationException; + } + + if (CategoryId == default) + { + var validationException = new ModelValidationException("CategoryId is invalid"); + validationException.ErrorResult.Title = "Kategori er ugyldig"; + throw validationException; + } + } + + public void Update(Transaction data) + { + Amount = data.Amount; + Date = data.Date; + Note = data.Note; + Tags = data.Tags; + CategoryId = data.CategoryId; + PayeeId = data.PayeeId; + base.Update(data); + } + } +} -- cgit v1.3