/// <summary> /// Update unit /// </summary> /// <param name="unit">unit</param> /// <returns></returns> public async Task <bool> UpdateUnitAsync(UnitRequest unit) { var data = await _repository.GetUnitById(unit.Id); data.UnitName = unit.UnitName; data.ModifiedBy = unit.ModifiedBy; data.ModifiedDate = DateTime.Now; return(await _repository.UpdateUnitAsync(data)); }
public async Task <IActionResult> Put(int unitId, [FromBody] Unit unit) { if (!ModelState.IsValid) { return(new BadRequestResult()); } if (!await _db.IsExistingUnitAsync(unitId)) { return(new NotFoundResult()); } await _db.UpdateUnitAsync(unit); return(new NoContentResult()); }