예제 #1
0
 private bool IsFacebookNotificationResponseValid(StartPoemModel startPoem)
 {
     return startPoem.FacebookNotificationResponse != null && startPoem.FacebookNotificationResponse.Request >= 0
            && startPoem.FacebookNotificationResponse.To != null
            && startPoem.FacebookNotificationResponse.To.Count != 0;
 }
예제 #2
0
        private bool IsStartRequestValid(StartPoemModel startPoem, VerseEngineeringUser user)
        {
            if (!ModelState.IsValid)
            {
                return false;
            }

            if (!IsFacebookNotificationResponseValid(startPoem))
            {
                logger.Error(
                    string.Format(
                        "Facebook notification response is invalid\n {0}", startPoem.FacebookNotificationResponse));
                return false;
            }

            if (user == null)
            {
                logger.Error(string.Format("VerseEngineeringUser is null after authorization"));
                return false;
            }

            return true;
        }
예제 #3
0
        public ActionResult Start(StartPoemModel startPoem, VerseEngineeringUser user)
        {
            if (!IsStartRequestValid(startPoem, user))
            {
                return View(startPoem);
            }

            if (user == null)
            {
                logger.Error(string.Format("VerseEngineeringUser is null after authorization"));
                return View(startPoem);
            }

            StartPoemConfiguration poemConfig = new ClassicalPoemConfiguration(
                user.UserId,
                startPoem.PoemTitle,
                startPoem.PoemDescription,
                startPoem.FacebookNotificationResponse.To,
                startPoem.FacebookNotificationResponse.Request);

            long poemId = poemService.StartNewPoem(poemConfig);

            return RedirectToAction("Play", new { poemId });
        }