public async Task <CatergoryImageModel> PutAsync(Guid id, [FromBody] CatergoryImageModel model)
        {
            var item = await _imageQueryProcessor.Update(id, model);

            var resultModel = _mapper.Map <CatergoryImageModel>(item);

            return(resultModel);
        }
        public async Task <CatergoryImageModel> PostAsync([FromBody] CatergoryImageModel model)
        {
            var item = await _imageQueryProcessor.Create(model);

            var resultModel = _mapper.Map <CatergoryImageModel>(item);

            return(resultModel);
        }
Exemple #3
0
        public async Task <CategoryImageEntity> Update(Guid id, CatergoryImageModel model)
        {
            var image = GetQuery().FirstOrDefault(b => b.Id == id);

            if (image == null)
            {
                throw new NotFoundException("image not found");
            }


            await _uniOfWork.CommitAsync();

            return(image);
        }
Exemple #4
0
        public async Task <CategoryImageEntity> Create(CatergoryImageModel model)
        {
            var image = new CategoryImageEntity
            {
                Id  = Guid.NewGuid(),
                Url = model.Url,
                CategoryEntityId = model.CategoryEntityId,
                CreateDate       = DateTime.UtcNow.ToLocalTime(),
                CreateUserId     = model.CreateUserId,
                ModifyDate       = DateTime.UtcNow.ToLocalTime(),
                ModifyUserId     = model.ModifyUserId,
                IsDeleted        = false,
                StatusId         = 1
            };

            _uniOfWork.Add(image);
            await _uniOfWork.CommitAsync();

            return(image);
        }