Ejemplo n.º 1
0
        public ActionResult Delete(string id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                var user            = _accountRepository.GetUsers().Single(x => x.UserId == id);
                var initiativeHeads = _initiativeBusiness.GetInitiativesByDeveloperOwner(user.UserName);
                var initiatives     = initiativeHeads.Select(initiativeHead => _initiativeBusiness.GetInitiative(initiativeHead.Id)).ToList();

                foreach (var initiative in initiatives)
                {
                    if (initiative.DeveloperRoles.Any(x => (x.DeveloperName == user.UserName) && x.RoleName.Equals(RoleNameConstants.Administrator)))
                    {
                        initiative.DeveloperRoles.Single(x => (x.DeveloperName == user.UserName) && x.RoleName.Equals(RoleNameConstants.Administrator)).RoleName = RoleNameConstants.Deleted;
                        _initiativeBusiness.UpdateInitiative(initiative);
                    }
                }

                _accountRepository.DeleteUser(id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult ResendInvite(string initiativeid, string code)
        {
            var initiative    = _initiativeBusiness.GetInitiative(Guid.Parse(initiativeid));
            var developerRole = initiative.DeveloperRoles.Single(x => x.InviteCode == code);
            var ins           = _initiativeBusiness.GetInitiativesByDeveloperOwner(_accountRepository.FindById(User.Identity.GetUserId()).Email).ToArray();

            var model = new InviteMemberModel()
            {
                InitiativeId = initiativeid,
                Developer    = developerRole,
                UniqueInitiativeIdentifier = initiative.GetUniqueIdentifier(ins.Select(x => x.Name))
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public ApplicationViewModel GetApplicationModel(IInitiative initiative, string application, IEnumerable <IApplicationVersion> versions)
        {
            var developerName   = _accountRepository.FindById(User.Identity.GetUserId()).Email;
            var initiativeHeads = _initiativeBusiness.GetInitiativesByDeveloperOwner(developerName).ToArray();

            var initiativeUniqueIdentifier = initiative.GetUniqueIdentifier(initiativeHeads.Select(xx => xx.Name));

            var applicationVersions = versions as IApplicationVersion[] ?? versions.ToArray();

            var model = new ApplicationViewModel
            {
                InitiativeId               = initiative.Id,
                InitiativeName             = initiative.Name,
                InitiativeUniqueIdentifier = initiativeUniqueIdentifier,
                Application = application,

                Versions = applicationVersions.Select(x => new VersionViewModel
                {
                    Checked               = false,
                    Build                 = x.BuildTime == null ? string.Empty : x.BuildTime.Value.ToLocalTime().ToDateTimeString(),
                    VersionId             = x.Id,
                    Version               = x.Version,
                    VersionIdentifier     = x.GetUniqueIdentifier(applicationVersions.Select(y => y.Version)),
                    ApplicationIdentifier = application,
                    InitiativeIdentifier  = initiativeUniqueIdentifier,
                    IssueTypeCount        = x.IssueTypes.Count(),
                    IssueCount            = x.IssueTypes.SelectMany(y => y.Issues).Count(),
                    Environments          = x.Environments
                }).OrderByDescending(y => y.Version).ToList(),
            };

            var envs = applicationVersions.SelectMany(x => x.Environments).Distinct().ToArray();
            var environmentColors = _initiativeBusiness.GetEnvironmentColors(User.Identity.GetUserId(), _accountRepository.FindById(User.Identity.GetUserId()).UserName).ToArray();

            model.EnvironmentColors = (from environmentColor in environmentColors where envs.Any(x => x == environmentColor.Key) select new EnvironmentViewModel()
            {
                Name = environmentColor.Key, Color = environmentColor.Value
            }).ToList();

            return(model);
        }