Example #1
0
        // GET
        public ActionResult Edit(int?memberId)
        {
            if (memberId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var member = unitOfWork.MemberRepository.FindMemberById(memberId);

            if (member == null)
            {
                return(HttpNotFound());
            }

            var needsCommunion = unitOfWork.NeedsCommunionRepository
                                 .Find(c => c.MemberId == memberId, firstOrDefault: true);
            var viewModel = new NeedsCommunionViewModel
            {
                MemberId     = member.Id,
                FirstName    = member.FirstName,
                LastName     = member.LastName,
                LastSelected = needsCommunion?.Timestamp,
                // User cannot select a member more than once per day
                SelectionAllowed = _service.IsSelectionAllowed(needsCommunion)
            };

            return(View(viewModel));
        }
Example #2
0
        public ActionResult Edit(NeedsCommunionViewModel viewModel)
        {
            if (!viewModel.NeedsCommunion)
            {
                return(Redirect(viewModel.ReturnUrl));
            }
            var needsCommunion = new NeedsCommunion
            {
                MemberId  = viewModel.MemberId,
                Timestamp = DateTime.Now
            };

            unitOfWork.NeedsCommunionRepository.Add(needsCommunion);

            return(Redirect(viewModel.ReturnUrl));
        }