Пример #1
0
        public async Task <IActionResult> EditProfile()
        {
            var user = await userManager.FindByIdAsync(User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (user == null)
            {
                ViewBag.ErrorMessage = $"User with ID = {user.Id} cannot be found";
                return(View("NotFound"));
            }

            var sportObject = sportObjectRepository.GetByEmail(user.Email);
            var tournament  = tournamentRepository.GetByEmail(user.Email);
            var sportSchool = sportSchoolRepository.GetByEmail(user.Email);

            if (sportObject != null)
            {
                return(RedirectToAction("EditSportObject", new { id = sportObject.Id }));
            }
            else if (tournament != null)
            {
                return(RedirectToAction("EditTournament", new { id = tournament.Id }));
            }
            else if (sportSchool != null)
            {
                return(RedirectToAction("EditSportSchool", new { id = sportSchool.Id }));
            }

            ViewBag.ErrorMessage = $"Ne posedujete svoj objekat";
            return(View("NotFound"));
        }
        public IActionResult IsEmailInUse(string email)
        {
            var sportObject = sportObjectRepository.GetByEmail(email);
            var tournament  = tournamentRepository.GetByEmail(email);
            var sportSchool = sportSchoolRepository.GetByEmail(email);

            if (sportObject != null || tournament != null || sportSchool != null)
            {
                return(Json($"Email {email} je vec iskoriscen"));
            }
            else
            {
                return(Json(true));
            }
        }