Ejemplo n.º 1
0
        public ActionResult Approve(int id, int environmentid)
        {
            Package package = this.Entities.Package
                              .Include("ApprovedOnEnvironments")
                              .First(p => p.Id == id);

            Environment environment = this.Entities.Environment.First(e => e.Id == environmentid);

            if (!environment.GetBoolProperty("AllowTestDeployment", false))
            {
                this.CheckPermission(UserRoleAction.ReleaseApprove);
            }

            if (package.ApprovedOnEnvironments.Any(a => a.Environment == environment))
            {
                return(this.RedirectToAction("Details", new { id }));
            }

            PackageApprovedOnEnvironment onEnvironment = new PackageApprovedOnEnvironment();

            onEnvironment.Package          = package;
            onEnvironment.Environment      = environment;
            onEnvironment.ApprovedDate     = DateTime.UtcNow;
            onEnvironment.ApprovedByUserId = this.ActiveUser.Id;

            this.Entities.PackageApprovedOnEnvironment.Add(onEnvironment);
            this.Entities.SaveChanges();

            return(this.RedirectToAction("Details", new { id }));
        }
Ejemplo n.º 2
0
        public ActionResult Reject(int id, int environmentid)
        {
            Package package = this.Entities.Package
                              .Include("ApprovedOnEnvironments.ApprovedBy")
                              .First(p => p.Id == id);

            Environment environment = this.Entities.Environment.First(e => e.Id == environmentid);

            if (!environment.GetBoolProperty("AllowTestDeployment", false))
            {
                this.CheckPermission(UserRoleAction.ReleaseApprove);
            }

            PackageApprovedOnEnvironment packageApprovedOnEnvironment = package.ApprovedOnEnvironments.FirstOrDefault(a => a.Environment == environment);

            if (packageApprovedOnEnvironment == null)
            {
                return(this.RedirectToAction("Details", new { id }));
            }

            this.Entities.PackageApprovedOnEnvironment.Remove(packageApprovedOnEnvironment);
            this.Entities.SaveChanges();

            return(this.RedirectToAction("Details", new { id }));
        }