コード例 #1
0
        public async Task <EntityActionOutcome> CreateEntityAsync(WebsiteInputData viewData)
        {
            var newEntity = _factory.Create(viewData);
            var validator = new WebsiteInputDataValidator();
            var result    = validator.Validate(viewData);

            if (result.IsValid == false)
            {
                return(EntityActionOutcome.MissingFullEntityData);
            }

            var upsertSuccessful = await _repository.AddAsync(newEntity);

            if (upsertSuccessful == null)
            {
                return(EntityActionOutcome.CreateFailed);
            }

            return(EntityActionOutcome.Success);
        }
コード例 #2
0
        public async Task <EntityActionOutcome> UpdateEntityAsync(WebsiteInputData viewData, Guid id)
        {
            var getCurrent = await _repository.GetByIdAsync <Website>(id);

            var validator = new WebsiteInputDataValidator();
            var result    = validator.Validate(viewData);

            if (result.IsValid == false)
            {
                return(EntityActionOutcome.UpdateFailed);
            }

            var updateSuccessful = _repository.Update(await PopulateEntityDataWithViewData(viewData, id));

            if (updateSuccessful == null)
            {
                return(EntityActionOutcome.EntityNotFound);
            }

            return(EntityActionOutcome.Success);
        }