Example #1
0
        public virtual async Task <UpdateResponse <ApiFamilyServerResponseModel> > Update(
            int id,
            ApiFamilyServerRequestModel model)
        {
            var validationResult = await this.FamilyModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Family record = this.DalFamilyMapper.MapModelToEntity(id, model);
                await this.FamilyRepository.Update(record);

                record = await this.FamilyRepository.Get(id);

                ApiFamilyServerResponseModel apiModel = this.DalFamilyMapper.MapEntityToModel(record);
                await this.mediator.Publish(new FamilyUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiFamilyServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiFamilyServerResponseModel> .UpdateResponse(validationResult));
            }
        }