Ejemplo n.º 1
0
        public IActionResult Event()
        {
            var             viewModel     = new SplitEventVM();
            List <Currency> allCurrencies = mysticoContext.GetAllCurrencies();

            viewModel.CurrencyItem = Library.ConvertCurrencyToSelectListItem(allCurrencies);

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Event(SplitEventVM viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            Event newEvent = mysticoContext.CreateEvent(viewModel);
            var   myUser   = await userManager.GetUserAsync(HttpContext.User);

            User user = mysticoContext.GetUserByAspUserId(myUser.Id);

            mysticoContext.AddLoggedInUserToEvent(user.Id, newEvent.Id);
            mysticoContext.AddParticipantsToEvent(viewModel.FriendIds, newEvent.Id);

            return(RedirectToAction(nameof(SplitController.Overview), nameof(SplitController).Replace("Controller", ""), new { id = newEvent.Id }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> UpdateEvent(int id, SplitEventVM viewModel)
        {
            var myUser = await userManager.GetUserAsync(HttpContext.User);

            User user = mysticoContext.GetUserByAspUserId(myUser.Id);

            var myEvent = mysticoContext.GetEventById(id);

            if (myEvent.ParticipantsInEvent.Where(p => p.UserId == user.Id).Count() == 0)
            {
                return(RedirectToAction(nameof(SplitController.Overview), nameof(SplitController).Replace("Controller", ""), new { id = myEvent.Id }));
            }

            await mysticoContext.UpdateEvent(myEvent, viewModel);

            mysticoContext.AddParticipantsToEvent(viewModel.FriendIds, id);

            return(RedirectToAction(nameof(SplitController.Overview), nameof(SplitController).Replace("Controller", ""), new { id = myEvent.Id }));
        }