public bool IsSelectionAllowed(NeedsCommunion needsCommunion) { if (needsCommunion == null) { return(true); } // if year or day != today's date then return true return(needsCommunion.Timestamp.Year != DateTime.Today.Year || needsCommunion.Timestamp.DayOfYear != DateTime.Today.DayOfYear); }
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)); }