Esempio n. 1
0
        public virtual ApiFileTypeClientRequestModel MapServerResponseToClientRequest(
            ApiFileTypeServerResponseModel response)
        {
            var request = new ApiFileTypeClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Esempio n. 2
0
        public virtual ApiFileTypeServerResponseModel MapEntityToModel(
            FileType item)
        {
            var model = new ApiFileTypeServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name);

            return(model);
        }
Esempio n. 3
0
        public virtual ApiFileTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiFileTypeServerRequestModel request)
        {
            var response = new ApiFileTypeServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Esempio n. 4
0
        public void MapEntityToModel()
        {
            var      mapper = new DALFileTypeMapper();
            FileType item   = new FileType();

            item.SetProperties(1, "A");
            ApiFileTypeServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Esempio n. 5
0
        public virtual ApiFileServerResponseModel MapEntityToModel(
            File item)
        {
            var model = new ApiFileServerResponseModel();

            model.SetProperties(item.Id,
                                item.BucketId,
                                item.DateCreated,
                                item.Description,
                                item.Expiration,
                                item.Extension,
                                item.ExternalId,
                                item.FileSizeInByte,
                                item.FileTypeId,
                                item.Location,
                                item.PrivateKey,
                                item.PublicKey);
            if (item.BucketIdNavigation != null)
            {
                var bucketIdModel = new ApiBucketServerResponseModel();
                bucketIdModel.SetProperties(
                    item.BucketIdNavigation.Id,
                    item.BucketIdNavigation.ExternalId,
                    item.BucketIdNavigation.Name);

                model.SetBucketIdNavigation(bucketIdModel);
            }

            if (item.FileTypeIdNavigation != null)
            {
                var fileTypeIdModel = new ApiFileTypeServerResponseModel();
                fileTypeIdModel.SetProperties(
                    item.FileTypeIdNavigation.Id,
                    item.FileTypeIdNavigation.Name);

                model.SetFileTypeIdNavigation(fileTypeIdModel);
            }

            return(model);
        }
Esempio n. 6
0
        public virtual async Task <UpdateResponse <ApiFileTypeServerResponseModel> > Update(
            int id,
            ApiFileTypeServerRequestModel model)
        {
            var validationResult = await this.FileTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                FileType record = this.DalFileTypeMapper.MapModelToEntity(id, model);
                await this.FileTypeRepository.Update(record);

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

                ApiFileTypeServerResponseModel apiModel = this.DalFileTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new FileTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiFileTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiFileTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Esempio n. 7
0
 public FileTypeUpdatedNotification(ApiFileTypeServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetFileTypeIdNavigation(ApiFileTypeServerResponseModel value)
 {
     this.FileTypeIdNavigation = value;
 }