Exemple #1
0
        public void SaveInitiative(IInitiative initiative)
        {
            if (initiative.Name == string.Empty)
            {
                initiative.Name = null;
            }

            _repository.UpdateInitiative(initiative);
        }
Exemple #2
0
        private static IApplicationGroup GetDefaultApplicationGroup(IInitiative initiative)
        {
            var applicationGroup = initiative.ApplicationGroups.SingleOrDefault(x => x.Name == null);

            if (applicationGroup == null)
            {
                applicationGroup = new ApplicationGroup(null, new List <IApplication>());
                initiative.AddApplicationGroup(applicationGroup);
            }
            return(applicationGroup);
        }
Exemple #3
0
        public static InitiativeViewModel ToModel(this IInitiative item, IEnumerable <string> allInitiativeNames)
        {
            var dateCreated = (item.ApplicationGroups.SelectMany(x => x.Applications)).Select(y => y.FirstRegistered).OrderBy(z => z.Date).FirstOrDefault();

            var response = new InitiativeViewModel
            {
                Id                 = item.Id,
                Name               = item.Name,
                ClientToken        = item.ClientToken,
                OwnerDeveloperName = item.OwnerDeveloperName,
                DeveloperRoles     = item.DeveloperRoles.Select(x => x.ToModel()).ToArray(),
                ApplicationCount   = item.ApplicationGroups.SelectMany(x => x.Applications).Count().ToString(),
                Sessions           = (item.ApplicationGroups.SelectMany(x => x.Applications)).Select(y => y.Id).ToString(),
                FirstUsedDate      = dateCreated == new DateTime() ? "N/A" : dateCreated.ToShortDateString() + " " + dateCreated.ToShortTimeString(),
                ApplicationGroups  = item.ApplicationGroups.Select(x => x.ToModel()).ToArray(),
                UniqueIdentifier   = item.GetUniqueIdentifier(allInitiativeNames),
            };

            return(response);
        }
Exemple #4
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);
        }
Exemple #5
0
 public void AddInitiative(IInitiative initiative)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
        public static InitiativePersist ToPersist(this IInitiative item)
        {
            var response = Mapper.Map <IInitiative, InitiativePersist>(item);

            return(response);
        }
Exemple #7
0
 public void UpdateInitiative(IInitiative initiative)
 {
     Database.GetCollection("Initiative").Save(initiative.ToPersist(), WriteConcern.Acknowledged);
 }
Exemple #8
0
 public void AddInitiative(IInitiative initiative)
 {
     Database.GetCollection("Initiative").Insert(initiative.ToPersist(), WriteConcern.Acknowledged);
 }
Exemple #9
0
        public void UpdateInitiative(IInitiative initiative)
        {
            var ini = new Initiative(initiative.Id, initiative.Name, initiative.ClientToken, initiative.OwnerDeveloperName, initiative.DeveloperRoles, initiative.ApplicationGroups.Where(x => x.Applications.Any()));

            _repository.UpdateInitiative(ini);
        }