public string getTransactionType(string description) { description = description.ToUpper(); if (Deposit.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.Deposit.ToString()); } else if (PaymentMade.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.PaymentMade.ToString()); } else if (PaymentReceived.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.PaymentReceived.ToString()); } else if (PointOfSale.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.PointOfSale.ToString()); } else if (Withdrawal.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.Withdrawal.ToString()); } else if (OverseePurchase.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.OverseePurchase.ToString()); } else if (TransactionCharges.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.TransactionCharges.ToString()); } else if (AdminCharges.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.AdminCharges.ToString()); } else if (PrepaidAirtime.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.PrepaidAirtime.ToString()); } else if (MonthlyAccountCharges.Any(n => description.IndexOf(n) != -1)) { return(Enumerators.TransactionType.MonthlyAccountCharges.ToString()); } // Extend transaction type here else { return(Enumerators.TransactionType.Unknown.ToString()); } }
public void SeedPaymentMadeForTestUser(string categoryName, decimal amount, DateTime paymentDate) { using (var context = new ApplicationDbContext()) { var paymentMade = new PaymentMade() { CategoryId = context.Categories.SingleOrDefault(c => c.Name == categoryName && c.UserId == _userId).Id, MonthId = context.Months.SingleOrDefault(m => m.BeginDate.Month == paymentDate.Month && m.BeginDate.Year == paymentDate.Year && m.UserId == _userId).Id, Amount = amount, PaymentDate = paymentDate, UserId = _userId }; context.PaymentsMade.Add(paymentMade); context.SaveChanges(); } }
public bool CreatePaymentMade(PaymentMadeCreate model) { using (var context = new ApplicationDbContext()) { var paymentMadeEntity = new PaymentMade() { CategoryId = context.Categories.SingleOrDefault(c => c.Name == model.CategoryName && c.UserId == _userId).Id, MonthId = context.Months.SingleOrDefault(m => m.BeginDate.Month == DateTime.Now.Month && m.BeginDate.Year == DateTime.Now.Year && m.UserId == _userId).Id, Amount = model.Amount, PaymentDate = DateTime.Now, UserId = _userId }; context.PaymentsMade.Add(paymentMadeEntity); return(context.SaveChanges() == 1); } }