public void Rename(string newName) { if (newName != Name) { Apply(new EntityTypeRenamedEvent(EntityTypeId, newName, GuidComb.Generate())); } }
public async Task Publish(IEnumerable <NewReviewDiscussion> discussions, Dictionary <string, Guid> newCommentsMap, Dictionary <string, Guid> newDiscussionsMap) { foreach (var discussion in discussions) { var commentId = GuidComb.Generate(); var discussionId = GuidComb.Generate(); newCommentsMap[discussion.TemporaryId] = commentId; newDiscussionsMap[discussion.TemporaryId] = discussionId; var review = _reviewForRevision(discussion.TargetRevisionId); _sessionAdapter.Save(new ReviewDiscussion { Id = discussionId, RevisionId = review.RevisionId, State = discussion.State.AsCommentState(), RootComment = new Comment { Id = commentId, Content = discussion.Content, PostedInReviewId = review.Id, CreatedAt = DateTimeOffset.UtcNow } }); } }
public void Rename(string newName) { if (newName != Name) { Apply(new DomainRenamedEvent(DomainId, newName, GuidComb.Generate())); } }
public async Task <IActionResult> Add(AddDomainRequest request) { var id = GuidComb.Generate(); var command = new AddDomainCommand(id, request.Name); await _addDomainCommandHandler.Handle(command); return(Ok(id)); }
public static RevisionFile FromDiff(FileDiff file) { return(new RevisionFile { Id = GuidComb.Generate(), File = file.Path, IsNew = file.NewFile, IsDeleted = file.DeletedFile, IsRenamed = file.RenamedFile }); }
public void AddAbstractStatus() { var a = dm.CreateObject <AbstractStatus>(); a.Id = GuidComb.Generate(); dm.AddAbstractStatus(a); var vm = new AbstractStatusViewModel(a); AllAbstractStatuses.Add(vm); CurrentAbstractStatus = vm; }
private void AddSex() { Sex s = this.dm.CreateObject <Sex>(); s.Id = GuidComb.Generate(); this.dm.AddSex(s); SexViewModel vm = new SexViewModel(s); this.AllSexes.Add(vm); this.CurrentSex = vm; }
/// <summary> /// Handles addition a new department to the workspace and model /// </summary> private void AddSpeciality() { Speciality sp = this.dm.CreateObject <Speciality>(); sp.Id = GuidComb.Generate(); this.dm.AddSpeciality(sp); SpecialityViewModel vm = new SpecialityViewModel(sp); this.AllSpecialities.Add(vm); this.CurrentSpeciality = vm; }
public void AddOrderStatus() { OrderStatus c = this.dm.CreateObject <OrderStatus>(); c.Id = GuidComb.Generate(); dm.AddOrderStatus(c); OrderStatusViewModel vm = new OrderStatusViewModel(c); AllOrderStatuss.Add(vm); CurrentOrderStatus = vm; }
private void Add() { var obj = DataManager.Instance.CreateObject <BadgesDefault>(); obj.Id = GuidComb.Generate(); obj.RankId = DataManager.Instance.GetAllRanks().FirstOrDefault().Id; obj.BadgeTypeId = DataManager.Instance.GetAllBadges().FirstOrDefault().Id; DataManager.Instance.AddBadgesDefault(obj); BadgesDefaultsCollection.Add(new ListBoxBadgeDefault(obj)); OnPropertyChanged("BadgesDefaultsCollection"); BadgeDefaultSelected = new ListBoxBadgeDefault(obj); }
public void AddConference() { Conference c = this.dm.CreateObject <Conference>(); c.Id = GuidComb.Generate(); dm.AddConference(c); ConferenceViewModel vm = new ConferenceViewModel(c); AllConferences.Add(vm); CurrentConference = vm; }
private void AddScienceDegree() { ScienceDegree sd = this.dm.CreateObject <ScienceDegree>(); sd.Id = GuidComb.Generate(); this.dm.AddScienceDegree(sd); ScienceDegreeViewModel vm = new ScienceDegreeViewModel(sd); this.AllScienceDegrees.Add(vm); this.CurrentScienceDegree = vm; }
public void AddRank() { var c = this.dm.CreateObject <Rank>(); c.Id = GuidComb.Generate(); dm.AddRank(c); var vm = new RankViewModel(c); AllRanks.Add(vm); CurrentRank = vm; }
public void AddPaymentType() { PaymentType c = this.dm.CreateObject <PaymentType>(); c.Id = GuidComb.Generate(); dm.AddPaymentType(c); PaymentTypeViewModel vm = new PaymentTypeViewModel(c); AllPaymentTypes.Add(vm); CurrentPaymentType = vm; }
public void AddUser() { User c = this.dm.CreateObject <User>(); c.Id = GuidComb.Generate(); dm.AddUser(c); UserViewModel vm = new UserViewModel(c); AllUsers.Add(vm); CurrentUser = vm; }
private void AddScienceStatus() { ScienceStatus ss = this.dm.CreateObject <ScienceStatus>(); ss.Id = GuidComb.Generate(); this.dm.AddScienceStatus(ss); ScienceStatusViewModel vm = new ScienceStatusViewModel(ss); this.AllScienceStatuses.Add(vm); this.CurrentScienceStatus = vm; }
public void AddCompany() { Company c = this.dm.CreateObject <Company>(); c.Id = GuidComb.Generate(); dm.AddCompany(c); CompanyViewModel vm = new CompanyViewModel(c); AllCompanys.Add(vm); CurrentCompany = vm; }
private void AddContactType() { ContactType ct = this.dm.CreateObject <ContactType>(); ct.Id = GuidComb.Generate(); this.dm.AddContactType(ct); ContactTypeViewModel vm = new ContactTypeViewModel(ct); this.AllContactTypes.Add(vm); this.CurrentContactType = vm; }
public async Task <ReviewRevision> Create(ReviewIdentifier reviewId, int number, string baseCommit, string headCommit) { var revision = new ReviewRevision { Id = GuidComb.Generate(), ReviewId = reviewId, RevisionNumber = number, BaseCommit = baseCommit, HeadCommit = headCommit }; return(revision); }
private void Add() { try { var obj = DataManager.Instance.CreateObject <Printer>(); obj.Id = GuidComb.Generate(); obj.PrinterName = CurrentPrinterName; obj.ComputerName = CurrentComputer; obj.DocumentName = CurrentDocumentName; PrinterCollection.Add(DataManager.Instance.AddPrinter(obj)); } catch (Exception ex) { LogManager.Write(ex); } }
/// <summary> /// Saves the the state of the entity to be modified or created /// </summary> /// <param name="entity"></param> public virtual CommitAction Save <T>(T entity) where T : class, IEntity { if (entity.Id != Guid.Empty && this.Exists(entity)) { this.Update(entity); return(CommitAction.Update); } else { if (entity.Id == Guid.Empty) { entity.Id = GuidComb.Generate(); } this.Add(entity); return(CommitAction.Add); } }
public async Task Publish(List <Item> replies, Review review, Dictionary <string, Guid> newCommentsMap) { while (true) { var haveParent = replies.Where(x => !x.ParentId.StartsWith("REPLY-")).ToList(); if (!haveParent.Any()) { return; } foreach (var item in haveParent) { var id = GuidComb.Generate(); Guid parentId; if (newCommentsMap.TryGetValue(item.ParentId, out var savedParentId)) { parentId = savedParentId; } else { parentId = Guid.Parse(item.ParentId); } _sessionAdapter.Save(new Comment { Id = id, PostedInReviewId = review.Id, Content = item.Content, CreatedAt = DateTimeOffset.UtcNow, ParentId = parentId }); var nowHaveParent = replies.Where(x => x.ParentId == item.Id); foreach (var child in nowHaveParent) { child.ParentId = id.ToString(); } replies.Remove(item); } } }
public async Task <Review> FindOrCreateReview(PublishReview command, ReviewIdentifier reviewId, Guid revisionId) { var review = _sessionAdapter.GetReview(revisionId, _user); if (review == null) { review = new Review { Id = GuidComb.Generate(), RevisionId = revisionId, UserId = _user.Id }; } review.ReviewedAt = DateTimeOffset.Now; _sessionAdapter.Save(review); return(review); }
public async Task Publish(NewFileDiscussion[] discussions, Dictionary <string, Guid> newCommentsMap, Dictionary <string, Guid> newDiscussionsMap) { foreach (var discussion in discussions) { var commentId = GuidComb.Generate(); var discussionId = GuidComb.Generate(); newCommentsMap[discussion.TemporaryId] = commentId; newDiscussionsMap[discussion.TemporaryId] = discussionId; var review = _reviewForRevision(discussion.TargetRevisionId); var resolvedFileId = _resolveFileId(discussion.FileId); var currentRevision = _sessionAdapter.GetRevision(review.RevisionId); var prevRevision = _sessionAdapter.GetPreviousRevision(currentRevision); var currentEntry = _sessionAdapter.GetFileHistoryEntry(resolvedFileId, currentRevision); var prevEntry = _sessionAdapter.GetFileHistoryEntry(resolvedFileId, prevRevision); _sessionAdapter.Save(new FileDiscussion { RevisionId = review.RevisionId, Id = discussionId, FileId = resolvedFileId, File = PathPair.Make(prevEntry?.FileName ?? currentEntry.FileName, currentEntry.FileName), LineNumber = discussion.LineNumber, State = discussion.State.AsCommentState(), RootComment = new Comment { Id = commentId, PostedInReviewId = review.Id, Content = discussion.Content, CreatedAt = DateTimeOffset.UtcNow } }); } }
public Relationship(Guid relationshipId, string name, Guid leftSideConceptId, Guid rightSideConceptId) { Apply(new RelationshipAddedEvent(relationshipId, name, leftSideConceptId, rightSideConceptId, GuidComb.Generate())); }
public Concept(Guid conceptId, Guid domainId, string name, string description) { Apply(new ConceptAddedEvent(conceptId, domainId, name, description, GuidComb.Generate())); }
static void Main(string[] args) { var configuration = new ConfigurationBuilder() .AddJsonFile("appSettings.json", false, true) .Build(); using (var serviceProvider = RegisterDependencies(configuration)) { var configurationDbContext = serviceProvider.GetRequiredService <DddExampleDbContext>(); configurationDbContext.Database.Migrate(); var doctorId1 = GuidComb.Generate(); configurationDbContext.DoctorTables.Add(new DoctorTable { DoctorId = doctorId1, Name = "Dr. Hard Toget" }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId1, DayOfWeek = DayOfWeek.Monday, StartsAt = TimeSpan.FromHours(13), EndsAt = TimeSpan.FromHours(15), }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId1, DayOfWeek = DayOfWeek.Tuesday, StartsAt = TimeSpan.FromHours(13), EndsAt = TimeSpan.FromHours(15), }); var doctorId2 = GuidComb.Generate(); configurationDbContext.DoctorTables.Add(new DoctorTable { DoctorId = doctorId2, Name = "Dr. Easy Tosee" }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId2, DayOfWeek = DayOfWeek.Monday, StartsAt = TimeSpan.FromHours(9), EndsAt = TimeSpan.FromHours(18), }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId2, DayOfWeek = DayOfWeek.Tuesday, StartsAt = TimeSpan.FromHours(9), EndsAt = TimeSpan.FromHours(18), }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId2, DayOfWeek = DayOfWeek.Wednesday, StartsAt = TimeSpan.FromHours(9), EndsAt = TimeSpan.FromHours(18), }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId2, DayOfWeek = DayOfWeek.Thursday, StartsAt = TimeSpan.FromHours(9), EndsAt = TimeSpan.FromHours(18), }); configurationDbContext.DoctorAvailabilityTables.Add(new DoctorAvailabilityTable { DoctorAvailabilityId = GuidComb.Generate(), DoctorId = doctorId2, DayOfWeek = DayOfWeek.Friday, StartsAt = TimeSpan.FromHours(9), EndsAt = TimeSpan.FromHours(18), }); var patientId = GuidComb.Generate(); configurationDbContext.PatientTables.Add(new PatientTable { PatientId = patientId, Name = "Emile Agin" }); configurationDbContext.SaveChanges(); } }
public async Task <Dictionary <ClientFileId, (string, Guid)> > Fill() { var(previousRevId, previousHead) = _sessionAdapter.FindPreviousRevision(_currentRevision.ReviewId, _currentRevision.RevisionNumber, _currentRevision.BaseCommit); var diff = await _api.GetDiff(_currentRevision.ReviewId.ProjectId, previousHead, _currentRevision.HeadCommit); if (_features.For("dont-show-excesive-files-from-rebases").IsActive) { var fileHistoryEntries = await _sessionAdapter.GetReviewFileHistory(_currentRevision.ReviewId); diff = (await RelevantFilesFilter.Filter(diff, fileHistoryEntries, _currentRevision.ReviewId, _currentRevision.BaseCommit, _currentRevision.HeadCommit, _api)).ToList(); } TMP_FIllOldRevisionFiles(diff); var fileIds = _sessionAdapter.FetchFileIds(previousRevId); var clientFileIdMap = fileIds.ToDictionary(x => ClientFileId.Persistent(x.Key), x => (x.Value, x.Key)); var remainingDiffs = new HashSet <FileDiff>(diff); foreach (var(fileId, latestFileName) in fileIds) { var allMatchingDiffs = remainingDiffs.Where(x => x.Path.OldPath == latestFileName); if (allMatchingDiffs.Count() > 1) { Logger.Error($"More that one diff found for {latestFileName}"); } var matchingDiff = allMatchingDiffs.FirstOrDefault(); if (matchingDiff != null) { remainingDiffs.Remove(matchingDiff); } _sessionAdapter.Save(new FileHistoryEntry { Id = GuidComb.Generate(), RevisionId = _currentRevision.Id, ReviewId = _currentRevision.ReviewId, FileId = fileId, FileName = matchingDiff?.Path.NewPath ?? latestFileName, IsNew = matchingDiff?.NewFile ?? false, IsDeleted = matchingDiff?.DeletedFile ?? false, IsRenamed = matchingDiff?.RenamedFile ?? false, IsModified = matchingDiff != null }); } foreach (var file in remainingDiffs) { var fileId = GuidComb.Generate(); clientFileIdMap[ClientFileId.Provisional(file.Path)] = (file.Path.NewPath, fileId); if (file.RenamedFile) { _sessionAdapter.Save(new FileHistoryEntry { Id = GuidComb.Generate(), RevisionId = null, ReviewId = _currentRevision.ReviewId, FileId = fileId, FileName = file.Path.OldPath, IsNew = false, IsDeleted = false, IsRenamed = false, IsModified = false }); } _sessionAdapter.Save(new FileHistoryEntry { Id = GuidComb.Generate(), RevisionId = _currentRevision.Id, ReviewId = _currentRevision.ReviewId, FileId = fileId, FileName = file.Path.NewPath, IsNew = file.NewFile, IsDeleted = file.DeletedFile, IsRenamed = file.RenamedFile, IsModified = true }); } return(clientFileIdMap); }
public Domain(Guid domainId, string name) { Apply(new DomainAddedEvent(domainId, name, GuidComb.Generate())); }
public void Rename(string newName) { Apply(new ConceptRenamedEvent(ConceptId, newName, GuidComb.Generate())); }