コード例 #1
0
ファイル: SplitController.cs プロジェクト: SaraJenny/mystico
        public IActionResult Event()
        {
            var             viewModel     = new SplitEventVM();
            List <Currency> allCurrencies = mysticoContext.GetAllCurrencies();

            viewModel.CurrencyItem = Library.ConvertCurrencyToSelectListItem(allCurrencies);

            return(View(viewModel));
        }
コード例 #2
0
ファイル: SplitController.cs プロジェクト: SaraJenny/mystico
        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 }));
        }
コード例 #3
0
ファイル: SplitController.cs プロジェクト: SaraJenny/mystico
        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 }));
        }