Exemplo n.º 1
0
        public IActionResult DeleteProductAttribute([FromBody] ProductAttributeDTO request)
        {
            var response = new OperationResponse <ICollection>();

            try
            {
                var result = _productService.DeleteProductAttribute(request.Tasks);
                if (result.Any(fn => !string.IsNullOrEmpty(fn.Message)))
                {
                    response.State = ResponseState.ValidationError;
                    response.Data  = result.ToList();
                    return(new JsonResult(response));
                }
                else
                {
                    response.State = ResponseState.Success;
                }
            }
            catch (Exception exception)
            {
                response.State = ResponseState.Error;
                response.Messages.Add(exception.Message);
                _logger.LogError(exception, "Error in DeleteProductAttribute ==>" + exception.StackTrace, request);
            }
            return(new JsonResult(response));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> GetById(int id)
        {
            ProductAttributeDTO ProductAttribute = await ProductAttributeService.GetAll().Where(x => x.Id == id && !x.Deleted).ProjectTo <ProductAttributeDTO>().FirstOrDefaultAsync();

            if (ProductAttribute == null)
            {
                return(NotFound());
            }
            return(Ok(ProductAttribute));
        }
Exemplo n.º 3
0
        public async Task <IHttpActionResult> Create([FromBody] ProductAttributeDTO ProductAttributeDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var entity = ProductAttributeDto.ToEntity();

            entity.CreateUserId = User.Identity.GetUserId();
            entity.CreateTime   = DateTime.Now;
            await ProductAttributeService.InsertAsync(entity);

            return(Ok(entity.ToModel()));
        }
Exemplo n.º 4
0
 public static ProductAttribute ToEntity(this ProductAttributeDTO dto, ProductAttribute entity)
 {
     return(Mapper.Map(dto, entity));
 }
Exemplo n.º 5
0
 public static ProductAttribute ToEntity(this ProductAttributeDTO dto)
 {
     return(Mapper.Map <ProductAttributeDTO, ProductAttribute>(dto));
 }