コード例 #1
0
 public IActionResult Join(int tripId)
 {
     if (!tripTimeCollisionChecker.IsColliding(tripId, accountManager.GetUserId(HttpContext.User)))
     {
         TripUser tripUser = new TripUser
         {
             TripId = tripId,
             UserId = accountManager.GetUserId(HttpContext.User)
         };
         tripUserRepository.Add(tripUser);
     }
     else
     {
         htmlNotification.SetNotification(HttpContext.Session, "res-fail", "One of your trips is colliding with trip you are trying to join!!!");
     }
     return(RedirectToAction("index", "TripDetails", new { id = tripId }));
 }
コード例 #2
0
        public IActionResult Index(TripCreatorViewModel model, string answer)
        {
            if (!String.IsNullOrWhiteSpace(answer))
            {
                switch (answer)
                {
                case "Accept":
                    var message = model.GetErrorMessage(model);
                    if (ModelState.IsValid && message.Length == 0)
                    {
                        if (!tripTimeCollisionChecker.IsColliding(accountManager.GetUserId(HttpContext.User), model.Date, model.DateEnd))
                        {
                            ViewData["mapData"] = model.MapData;
                            return(View("ConfirmationPositive", model));
                        }
                        else
                        {
                            htmlNotification.SetNotification(HttpContext.Session, "res-fail", "One of your trips is colliding with trip you are trying to create!!!");
                            return(View("Index"));
                        }
                    }
                    else
                    {
                        htmlNotification.SetNotification(HttpContext.Session, "res-fail", message);
                        return(View("Index"));
                    }

                case "Decline":
                    return(RedirectToAction("Index", "Home"));

                default:
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                return(View());
            }
        }