public async Task <IActionResult> DeleteSpecField(int id, [FromServices] IProductSpecialFieldService productSpecialFieldService) { var productSField = await productSpecialFieldService.GetByIdAsync(id); if (productSField == null) { return(NotFound()); } await productSpecialFieldService.Delete(id); return(Ok()); }
public async Task <IActionResult> PutSpecField([FromBody] UpdateProductSpecFieldModel model, [FromServices] IProductSpecialFieldService productSpecialFieldService) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var productSField = await productSpecialFieldService.GetByIdAsync(model.Id); if (productSField == null) { return(NotFound()); } productSField.Value = model.Value; productSField = await productSpecialFieldService.Update(productSField); var view = await productSpecialFieldService.SingleOrDefaultAsync(sp => _mapper.Map <ProductSpecFieldModel>(sp), sp => sp.Id == productSField.Id, sp => sp.Include(d => d.SpecField)); return(Ok(view)); }