コード例 #1
0
        public IActionResult ConfirmationPositive(string answer, TripCreatorViewModel model)
        {
            if (!String.IsNullOrWhiteSpace(answer))
            {
                switch (answer)
                {
                case "Accept":
                    TripDetails tripDetails = model.GetTripDetailsModel();
                    tripDetails.DriverId = accountManager.GetUserId(HttpContext.User);

                    if (model.MapData != null)
                    {
                        var id = fileManager.SaveFile(model.MapData, "wwwroot/images/maps/");
                        tripDetails.MapId = id;
                    }

                    tripDetailsRepository.Add(tripDetails);
                    htmlNotification.SetNotification(HttpContext.Session, "res-suc", "Trip was succesfully created!");
                    return(RedirectToAction("Index", "Home"));

                case "Decline":
                    return(View("Index"));

                default:
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
コード例 #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());
            }
        }