public async Task <IHttpActionResult> GetById(int id) { ProductAttributeValueDTO ProductAttributeValue = await ProductAttributeValueService.GetAll().Where(x => x.Id == id && !x.Deleted).ProjectTo <ProductAttributeValueDTO>().FirstOrDefaultAsync(); if (ProductAttributeValue == null) { return(NotFound()); } return(Ok(ProductAttributeValue)); }
public async Task <IHttpActionResult> Create([FromBody] ProductAttributeValueDTO ProductAttributeValueDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = ProductAttributeValueDto.ToEntity(); entity.CreateUserId = User.Identity.GetUserId(); entity.CreateTime = DateTime.Now; await ProductAttributeValueService.InsertAsync(entity); return(Ok(entity.ToModel())); }
public static ProductAttributeValue ToEntity(this ProductAttributeValueDTO dto, ProductAttributeValue entity) { return(Mapper.Map(dto, entity)); }
public static ProductAttributeValue ToEntity(this ProductAttributeValueDTO dto) { return(Mapper.Map <ProductAttributeValueDTO, ProductAttributeValue>(dto)); }