public void Update(LedgerLog ledger) { TransactionId = ledger.TransactionId; Reference = ledger.Reference; Currency = ledger.Currency; Amount = ledger.Amount; Type = ledger.Type; Created = ledger.Created; }
public IResourceHandler saveTransaction() { var date = jToken.Value <DateTime>("date"); var time = jToken.Value <string>("time"); var ttime = TimeSpan.Parse(time); var amount = jToken.Value <decimal>("amount"); var desc = jToken.Value <string>("description"); var isOutcome = jToken.Value <bool>("isOutcome"); var idCategory = jToken.Value <long>("idCategory"); using (var model = new DataContext()) using (var trans = model.Database.BeginTransaction(IsolationLevel.Serializable)) { try { var log = new LedgerLog() { Id = LedgerLog.GenerateID(), IdCategory = idCategory, Date = date.Add(ttime), Description = desc, Debit = (isOutcome) ? 0 : amount, Kredit = (isOutcome) ? amount : 0, CreateAt = DateTime.Now, UpdateAt = DateTime.Now, }; model.LedgerLogs.Add(log); model.SaveChanges(); trans.Commit(); return(Json(new { success = true, data = log })); } catch { trans.Rollback(); return(Json(new { success = false })); } } }
public override void Run(DataContext context) { context.LedgerCategories.Add(new LedgerCategory() { Description = "Cash", Icon = "local_atm", Color = "light-green darken-3", IsExpense = false, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Income", Icon = "get_app", Color = "blue darken-3", IsExpense = false, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Salary", Icon = "group", Color = "yellow darken-4", IsExpense = false, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Food & Drinks", Icon = "restaurant", Color = "cyan darken-3", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Transportation", Icon = "local_airport", Color = "deep-orange darken-4", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Comunication", Icon = "local_phone", Color = "deep-purple darken-4", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Tax", Icon = "public", Color = "green darken-4", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Utilities", Icon = "build", Color = "amber darken-3", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Insurance", Icon = "business_center", Color = "brown darken-4", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Loan", Icon = "card_giftcard", Color = "cyan darken-2", IsExpense = true, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Uncategorized", Icon = "all_inclusive", Color = "black", IsExpense = false, }); context.LedgerCategories.Add(new LedgerCategory() { Description = "Uncategorized", Icon = "all_inclusive", Color = "black", IsExpense = true, }); context.SaveChanges(); context.LedgerLogs.Add(new LedgerLog() { Id = LedgerLog.GenerateID(), IdCategory = 1, Date = DateTime.Now, Debit = 0, Kredit = 0, IsClose = true, Description = "Initial Cash", UpdateAt = DateTime.Now, CreateAt = DateTime.Now }); }
public LedgerEntity(LedgerLog ledger) { Update(ledger); }