Exemplo n.º 1
0
 public void AddItem(int userId, LogEntry item)
 {
     var entry = new MoneyFlow
     {
         Id = 0,
         Category = item.Category.ToTitleCase(),
         Subcategory = (string.IsNullOrEmpty(item.Subcategory)) ? string.Empty : item.Subcategory.ToTitleCase(),
         Credit = (item.Direction == "credit") ? item.Value : 0m,
         Debit = (item.Direction == "debit") ? item.Value : 0m,
         Date = DateTime.Now,
         Item = item.Description
     };
     _moneyFlowRepository.SaveItem(userId, entry);
 }
 public void SaveItem(int userId, MoneyFlow moneyFlow)
 {
     if (moneyFlow.Id == 0)
     {
         moneyFlow.Date = DateTime.Now;
         GetUser(userId).MoneyFlows.Add(moneyFlow);
         _context.SubmitChanges();
     }
     else if (_context.MoneyFlows.GetOriginalEntityState(moneyFlow) == null)
     {
         _context.MoneyFlows.Attach(moneyFlow);
         _context.MoneyFlows.Context.Refresh(RefreshMode.KeepCurrentValues, moneyFlow);
         _context.MoneyFlows.Context.SubmitChanges();
     }
 }
 partial void DeleteMoneyFlow(MoneyFlow instance);
 partial void UpdateMoneyFlow(MoneyFlow instance);
 partial void InsertMoneyFlow(MoneyFlow instance);
		private void detach_MoneyFlows(MoneyFlow entity)
		{
			this.SendPropertyChanging();
			entity.User1 = null;
		}
		private void attach_MoneyFlows(MoneyFlow entity)
		{
			this.SendPropertyChanging();
			entity.User1 = this;
		}
 public void SaveItem(int userId, MoneyFlow moneyFlow)
 {
     throw new NotImplementedException();
 }