Пример #1
0
        public virtual async Task <ActionResult> ConfirmOwner(string id, string username, string token)
        {
            if (String.IsNullOrEmpty(token))
            {
                return(HttpNotFound());
            }

            if (!String.Equals(username, User.Identity.Name, StringComparison.OrdinalIgnoreCase))
            {
                return(View(new PackageOwnerConfirmationModel()
                {
                    Username = username,
                    Result = ConfirmOwnershipResult.NotYourRequest
                }));
            }

            var package = _packageService.FindPackageRegistrationById(id);

            if (package == null)
            {
                return(HttpNotFound());
            }

            var user = GetCurrentUser();
            ConfirmOwnershipResult result = await _packageService.ConfirmPackageOwnerAsync(package, user, token);

            var model = new PackageOwnerConfirmationModel
            {
                Result    = result,
                PackageId = package.Id
            };

            return(View(model));
        }