Example #1
0
        public IActionResult DoApplication(ApplicationViewModel model)
        {
            var usr = _authService.GetAuthUser(Request, Response);

            if (usr == null)
            {
                return(_authService.UnAuthenticatedResult);
            }
            var suc = new ActionResultViewModel
            {
                Title    = "Error !",
                SubTitle =
                    "Application was not sent successfully! Please check your image, also your title should be less then 30 characters.",
                TextClass        = "text-danger",
                ButtonClass      = "btn-danger",
                ActionButtonLink = "/MemeOff/Application",
                ActionButtonText = "Back to application"
            };

            if (String.IsNullOrWhiteSpace(model.Title) || model.Image == null)
            {
                return(new RedirectToActionResult("Result", "Home", routeValues: suc));
            }

            var ok = _competitionService.Apply(model, usr);

            if (ok)
            {
                suc.Title            = "Success !";
                suc.SubTitle         = "Application sent successfully!";
                suc.TextClass        = "text-success";
                suc.ButtonClass      = "btn-success";
                suc.ActionButtonLink = "/MemeOff/Index";
                suc.ActionButtonText = "Back to the contest";
            }
            return(new RedirectToActionResult("Result", "Home", routeValues: suc));
        }