Esempio n. 1
0
        public virtual ActionResult ContactAdmins(string id, string version, ContactAdminsViewModel reportForm)
        {
            if (!ModelState.IsValid)
            {
                return(ContactAdmins(id, version));
            }

            var package = packageSvc.FindPackageByIdAndVersion(id, version);

            if (package == null)
            {
                return(PackageNotFound(id, version));
            }

            MailAddress from = null;

            if (Request.IsAuthenticated)
            {
                var user = userSvc.FindByUsername(HttpContext.User.Identity.Name);
                from = user.ToMailAddress();
            }
            else
            {
                from = new MailAddress(reportForm.Email);
            }

            var packageUrl = EnsureTrailingSlash(Configuration.GetSiteRoot(UseHttps())) + RemoveStartingSlash(Url.Package(package));

            messageService.ContactSiteAdmins(from, package, reportForm.Message.clean_html(), packageUrl, reportForm.CopySender);

            TempData["Message"] = "Your message has been sent to the site admins.";
            return(RedirectToAction(MVC.Packages.DisplayPackage(id, version)));
        }
Esempio n. 2
0
        // NOTE: Intentionally NOT requiring authentication
        public virtual ActionResult ContactAdmins(string id, string version)
        {
            var package = packageSvc.FindPackageByIdAndVersion(id, version);

            if (package == null)
            {
                return(PackageNotFound(id, version));
            }

            var model = new ContactAdminsViewModel
            {
                PackageId      = id,
                PackageVersion = package.Version,
            };

            if (Request.IsAuthenticated)
            {
                var user = userSvc.FindByUsername(HttpContext.User.Identity.Name);
                if (user.Confirmed)
                {
                    model.ConfirmedUser = true;
                }
            }

            return(View("~/Views/Packages/ContactAdmins.cshtml", model));
        }