private void Apply(LanguageCreated @event) { Id = @event.AggregateRootId; SiteId = @event.SiteId; Name = @event.Name; CultureName = @event.CultureName; Url = @event.Url; SortOrder = @event.SortOrder; Status = @event.Status; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } LanguageStatus = await _context.LanguageStatus.FirstOrDefaultAsync(m => m.Id == id); if (LanguageStatus == null) { return(NotFound()); } return(Page()); }
public void Delete(DeleteLanguage cmd, IValidator <DeleteLanguage> validator) { validator.ValidateCommand(cmd); if (Status == LanguageStatus.Deleted) { throw new Exception("Language already deleted."); } Status = LanguageStatus.Deleted; AddEvent(new LanguageDeleted { SiteId = SiteId, AggregateRootId = Id }); }
public void Activate(ActivateLanguage cmd, IValidator <ActivateLanguage> validator) { validator.ValidateCommand(cmd); if (Status == LanguageStatus.Active) { throw new Exception("Language already active."); } Status = LanguageStatus.Active; AddEvent(new LanguageActivated { SiteId = SiteId, AggregateRootId = Id }); }
public bool IsLanguageStatus(Language language, LanguageStatus status) { LanguageStatus defaultStatus = LanguageStatus.First(); if (Game.ImplementedLanguages == null) { return(status.Id == defaultStatus.Id); } ImplementedLanguage implementedLanguage = Game.ImplementedLanguages.FirstOrDefault(il => il.LanguageId == language.Id); if (implementedLanguage == null) { return(status.Id == defaultStatus.Id); } return(status.Id == implementedLanguage.LanguageStatusId); }
private Language(CreateLanguage cmd, ILanguageSortOrderGenerator languageSortOrderGenerator) : base(cmd.Id) { SiteId = cmd.SiteId; Name = cmd.Name; CultureName = cmd.CultureName; Url = cmd.Url; SortOrder = languageSortOrderGenerator.GenerateNextSortOrder(cmd.SiteId); Status = LanguageStatus.Hidden; AddEvent(new LanguageCreated { SiteId = SiteId, AggregateRootId = Id, Name = Name, CultureName = CultureName, Url = Url, SortOrder = SortOrder, Status = Status }); }
public void Hide(HideLanguage cmd, IValidator <HideLanguage> validator) { validator.ValidateCommand(cmd); if (Status == LanguageStatus.Hidden) { throw new Exception("Language already hidden."); } if (Status == LanguageStatus.Deleted) { throw new Exception("Language is deleted."); } Status = LanguageStatus.Hidden; AddEvent(new LanguageHidden { SiteId = SiteId, AggregateRootId = Id }); }
private void Apply(LanguageDeleted @event) { Status = LanguageStatus.Deleted; }
private void Apply(LanguageHidden @event) { Status = LanguageStatus.Hidden; }
private void Apply(LanguageActivated @event) { Status = LanguageStatus.Active; }