Ejemplo n.º 1
0
        public ShowNoShowHangoutViewModel GetShowNoShow(int hangoutId)
        {
            var showNoShowHangoutViewModel = new ShowNoShowHangoutViewModel();
            var userHangout = (from a in AspNetUsers_Hangout_db.AspNetUsers_Hangouts
                               where a.HangoutId == hangoutId
                               select a);
            showNoShowHangoutViewModel.Id = hangoutId;

            foreach (var u in userHangout)
            {
                showNoShowHangoutViewModel.UserList.Add(new ShowOrNoShowUser
                {
                    AttendeeId = u.AspNetUsers,
                    Username = GetUserName(u.AspNetUsers),
                    Showed = u.Showed
                });
            }

            return showNoShowHangoutViewModel;
        }
Ejemplo n.º 2
0
        public void ShoworNoShowSubmit(ShowNoShowHangoutViewModel model)
        {
            foreach (var m in model.UserList)
            {
                var userHangout = (from a in AspNetUsers_Hangout_db.AspNetUsers_Hangouts
                                   where a.HangoutId == model.Id && a.AspNetUsers == m.AttendeeId
                                   select a).Single();
                userHangout.Showed = m.Showed;

                // Can I just make one submit call?
                try
                {
                    AspNetUsers_Hangout_db.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Provide for exceptions.
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult ShowNoShow(ShowNoShowHangoutViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userInfo = User.Identity.GetUserId();
                //model.AttendeeId = userInfo;
                _hangoutRepository.ShoworNoShowSubmit(model);

                return RedirectToAction("MyHangouts");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }