Exemple #1
0
        public Event CreateEvent(SplitEventVM viewModel)
        {
            var newEvent = new Event();

            newEvent.EventName          = viewModel.Name;
            newEvent.Description        = viewModel.Description;
            newEvent.IsActive           = true;
            newEvent.StandardCurrencyId = Convert.ToInt32(viewModel.SelectedCurrency);
            newEvent.ExpenseCurrencyId  = Convert.ToInt32(viewModel.ExpenseCurrencyId);

            Event.Add(newEvent);
            SaveChanges();

            return(newEvent);
        }
Exemple #2
0
        internal async Task UpdateEvent(Event myEvent, SplitEventVM viewModel)
        {
            myEvent.EventName         = viewModel.Name;
            myEvent.Description       = viewModel.Description;
            myEvent.ExpenseCurrencyId = Convert.ToInt32(viewModel.ExpenseCurrencyId);
            if (myEvent.StandardCurrencyId != Convert.ToInt32(viewModel.SelectedCurrency))
            {
                myEvent.StandardCurrencyId = Convert.ToInt32(viewModel.SelectedCurrency);

                SaveChanges();

                foreach (var expense in myEvent.Expense)
                {
                    await UpdateAmountInExpense(expense);
                }
            }


            SaveChanges();
        }