示例#1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Моля влезте в системата отново или си изчистете кеш данните на браузъра."));
            }

            var contestant = await _contestantsService.GetByIdAsync <ContestantViewModel>(id);

            if (contestant == null)
            {
                return(NotFound());
            }

            var poster = this._userManager.GetUserId(User);

            if (poster != contestant.PosterID)
            {
                return(Redirect($"/Identity/Account/AccessDenied"));
            }

            RequirePassword = await _userManager.HasPasswordAsync(user);

            return(Page());
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToPage("/Account/Errors/AccessDenied", new { Area = "Identity" }));
            }
            if (user.AccountType == 0)
            {
                return(RedirectToPage("/Account/Manage/Pricing", new { Area = "Identity" }));
            }
            var contestant = await _contestantService.GetByIdAsync(id);

            if (contestant == null)
            {
                return(RedirectToPage("/Account/Errors/NoEntity", new { Area = "Identity" }));
            }

            if (user.Id != contestant.PosterID && !user.Role.Equals(Roles.Admin) && !user.Role.Equals(Roles.Moderator))
            {
                return(RedirectToPage("/Account/Errors/AccessDeniedContent", new { Area = "Identity" }));
            }

            LoadData(contestant);

            Input = new InputModel
            {
                Id               = contestant.Id,
                FullName         = contestant.FullName,
                LocationId       = contestant.LocationId,
                WorkType         = contestant.WorkType,
                Description      = contestant.Description,
                Genders          = contestant.Genders,
                Age              = contestant.Age,
                About            = contestant.About,
                Experience       = contestant.Experience,
                SalaryType       = contestant.SalaryType,
                CategoryId       = contestant.CategoryId,
                payRate          = contestant.payRate,
                profileVisiblity = contestant.profileVisiblity,
                Website          = contestant.Website,
                Portfolio        = contestant.Portfolio,
                Facebook         = contestant.Facebook,
                Linkdin          = contestant.Linkdin,
                Twitter          = contestant.Twitter,
                Github           = contestant.Github,
                Dribbble         = contestant.Dribbble,
                ResumeFileId     = contestant.ResumeFileId,
                userSkillsId     = contestant.userSkillsId,
                LanguagesId      = contestant.LanguagesId
            };

            Input.resumeFullPath = _FilePath + contestant.ResumeFileId;

            User conUser = await _userManager.FindByIdAsync(contestant.PosterID);

            Input.ImagePath = (conUser.isExternal ? null : _ImagePath) + conUser.PictureName;
            return(Page());
        }
        public async Task <IActionResult> Details(int id)
        {
            var contestant = await _contestantsService.GetByIdAsync <ContestantViewModel>(id);

            if (contestant == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            return(this.View(contestant));
        }
示例#4
0
        public async Task <ActionResult> Approve(int id, ApproveType T, string returnUrl, [FromServices] IBaseService _baseService, [FromServices] INotificationService _notifyService)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(Redirect("/Identity/Account/Errors/AccessDenied"));
            }

            var entity = await _contestantsService.GetByIdAsync(id);

            if (entity == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            var result = await _baseService.Approve(id, PostType.Contestant, T);

            if (result.Success)
            {
                var PosterId = await _userManager.FindByIdAsync(entity.PosterID);

                if (!(PosterId is null))
                {
                    switch (T)
                    {
                    case ApproveType.Waiting:
                        await _notifyService.Create("Моля редактирайте вашата кандидатура отново с коректни данни.", "identity/contestant/index", DateTime.Now, NotifyType.Warning, "fas fa-sync-alt", PosterId);

                        break;

                    case ApproveType.Rejected:
                        await _notifyService.Create("Последно добавената ви кандидатура е отхвърлена.", "identity/contestant/index", DateTime.Now, NotifyType.Danger, "fas fa-ban", PosterId);

                        break;

                    case ApproveType.Success:
                        await _notifyService.Create("Последно добавената ви кандидатура е одобрена.", "identity/contestant/index", DateTime.Now, NotifyType.Information, "fas fa-check", PosterId);

                        break;
                    }
                }
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }

            return(View());
        }
示例#5
0
        public async Task <IActionResult> OnPostDeleteAsync(int id, string returnUrl)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(RedirectToPage("/Account/Errors/AccessDenied", new { Area = "Identity" }));
            }
            var hasPassword = await _userManager.HasPasswordAsync(user);

            if (!hasPassword)
            {
                return(RedirectToPage("./SetPassword"));
            }
            var contestant = await _contestantsService.GetByIdAsync(id);

            if (contestant == null)
            {
                return(RedirectToPage("/Account/Errors/NoEntity", new { Area = "Identity" }));
            }

            if (user.Id != contestant.PosterID && !user.Role.Equals(Roles.Admin) && !user.Role.Equals(Roles.Moderator))
            {
                return(RedirectToPage("/Account/Errors/AccessDeniedContent", new { Area = "Identity" }));
            }
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = await this._contestantsService.Delete(id);

            if (result.Success)
            {
                await _userManager.RemoveFromRoleAsync(user, "Contestant");

                await _userManager.AddToRoleAsync(user, "User");

                await _userManager.UpdateAsync(user);

                _baseService.ToastNotify(ToastMessageState.Warning, "Внимание", "Обявата е премахната успешно.", 2000);

                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    RedirectToPage("/Identity/Contestant", new { Area = "Identity" });
                }
            }

            return(Page());
        }
示例#6
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Моля влезте в системата отново или си изчистете кеш данните на браузъра."));
            }

            var contestant = await _contestantService.GetByIdAsync <ContestantViewModel>(id);

            if (contestant == null)
            {
                return(NotFound());
            }

            var poster = this._userManager.GetUserId(User);

            if (poster != contestant.PosterID)
            {
                return(Redirect($"/Identity/Account/AccessDenied"));
            }

            ViewData["Categories"] = this._categoriesService.GetAllAsNoTrackingMapped().Select(x => new SelectListItem
            {
                Value = x.Id.ToString(),
                Text  = x.TitleAndCountContestant,
            });

            ViewData["Locations"] = this._locationService.GetAllAsNoTrackingMapped().Select(x => new SelectListItem
            {
                Value = x.Id.ToString(),
                Text  = x.City,
            });

            Input = new InputModel
            {
                Id               = contestant.Id,
                Name             = contestant.Name,
                LocationId       = contestant.LocationId,
                WorkType         = contestant.WorkType,
                Description      = contestant.Description,
                Genders          = contestant.Genders,
                Age              = contestant.Age,
                About            = contestant.About,
                Experience       = contestant.Experience,
                SalaryType       = contestant.SalaryType,
                CategoryId       = contestant.CategoryId,
                payRate          = contestant.payRate,
                profileVisiblity = contestant.profileVisiblity,
                WebsiteUrl       = contestant.WebsiteUrl,
                PortfolioUrl     = contestant.PortfolioUrl,
                Facebook         = contestant.Facebook,
                Linkedin         = contestant.Linkedin,
                Twitter          = contestant.Twitter,
                Github           = contestant.Github,
                Dribbble         = contestant.Dribbble,
                ResumeFileId     = contestant.ResumeFileId,
                userSkillsId     = contestant.userSkillsId,
                LanguagesId      = contestant.LanguagesId
            };
            string imageUrl = _config.GetSection("MySettings").GetSection("SiteImageUrl").Value;

            Input.PictureUrl = imageUrl + user.PictureName;

            string siteUrl = _config.GetSection("MySettings").GetSection("SiteResumeUrl").Value;

            Input.resumeFullPath = siteUrl + contestant.ResumeFileId;

            return(Page());
        }