Esempio n. 1
0
        public virtual async Task <CreateResponse <ApiCallStatusServerResponseModel> > Create(
            ApiCallStatusServerRequestModel model)
        {
            CreateResponse <ApiCallStatusServerResponseModel> response = ValidationResponseFactory <ApiCallStatusServerResponseModel> .CreateResponse(await this.CallStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CallStatus record = this.DalCallStatusMapper.MapModelToEntity(default(int), model);
                record = await this.CallStatusRepository.Create(record);

                response.SetRecord(this.DalCallStatusMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CallStatusCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 2
0
        public virtual async Task <UpdateResponse <ApiCallStatusServerResponseModel> > Update(
            int id,
            ApiCallStatusServerRequestModel model)
        {
            var validationResult = await this.CallStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CallStatus record = this.DalCallStatusMapper.MapModelToEntity(id, model);
                await this.CallStatusRepository.Update(record);

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

                ApiCallStatusServerResponseModel apiModel = this.DalCallStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CallStatusUpdatedNotification(apiModel));

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