public void SaveInitiative(IInitiative initiative) { if (initiative.Name == string.Empty) { initiative.Name = null; } _repository.UpdateInitiative(initiative); }
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); }
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); }
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); }
public void AddInitiative(IInitiative initiative) { throw new NotImplementedException(); }
public static InitiativePersist ToPersist(this IInitiative item) { var response = Mapper.Map <IInitiative, InitiativePersist>(item); return(response); }
public void UpdateInitiative(IInitiative initiative) { Database.GetCollection("Initiative").Save(initiative.ToPersist(), WriteConcern.Acknowledged); }
public void AddInitiative(IInitiative initiative) { Database.GetCollection("Initiative").Insert(initiative.ToPersist(), WriteConcern.Acknowledged); }
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); }