예제 #1
0
 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;
 }
예제 #2
0
        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());
        }
예제 #3
0
파일: Language.cs 프로젝트: zdlian/Weapsy
        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
            });
        }
예제 #4
0
파일: Language.cs 프로젝트: zdlian/Weapsy
        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
            });
        }
예제 #5
0
        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);
        }
예제 #6
0
파일: Language.cs 프로젝트: zdlian/Weapsy
        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
            });
        }
예제 #7
0
파일: Language.cs 프로젝트: zdlian/Weapsy
        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
            });
        }
예제 #8
0
 private void Apply(LanguageDeleted @event)
 {
     Status = LanguageStatus.Deleted;
 }
예제 #9
0
 private void Apply(LanguageHidden @event)
 {
     Status = LanguageStatus.Hidden;
 }
예제 #10
0
 private void Apply(LanguageActivated @event)
 {
     Status = LanguageStatus.Active;
 }