public async Task <bool> Put(SupplierToCreateDTO supplier, int id) { var supplierFromRepo = await _unitOfWork.Supplier.GetById(id); _mapper.Map(supplier, supplierFromRepo); return(await _unitOfWork.SaveChanges()); }
public async Task <IActionResult> Put(int id, SupplierToCreateDTO supplierToCreate) { if (await _supplierService.Put(supplierToCreate, id)) { return(NoContent()); } return(BadRequest("Fail to update Product")); }
public async Task <SupplierToReturnDTO> Post(SupplierToCreateDTO product) { var supplierToCreate = _mapper.Map <Supplier>(product); _unitOfWork.Supplier.Add(supplierToCreate); if (await _unitOfWork.SaveChanges()) { return(_mapper.Map <SupplierToReturnDTO>(supplierToCreate)); } throw new Exception("Fail on creation"); }
public async Task <IActionResult> Post([FromBody] SupplierToCreateDTO supplierToCreate) { var supplier = await _supplierService.Post(supplierToCreate); return(CreatedAtRoute("GetSupplier", new { Id = supplier.SupplierId }, supplier)); }