public IActionResult Put([FromBody] RawMaterial model) { try { if (!ModelState.IsValid) { return(InvalidModelStateResult()); } if (!validateEntity(model)) { return(InvalidModelStateResult()); } if (repository.Get().Count(a => a.RawMaterialId.Equals(model.RawMaterialId)) == 0) { return(NotFound(Constants.ErrorMessages.NotFoundEntity)); } return(Accepted(repository.Update(model))); } catch (Exception ex) { logger.LogError(ex.GetExceptionMessages()); return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.UpdateError)); } }
public IActionResult Put(int id, [FromBody] RawMaterial model) { if (ModelState.IsValid) { model.RawMaterialId = id; _repository.Update(model); return(Ok(model)); } else { return(new ResponseResult(Response) { StatusCode = (int)StatusCodes.Status400BadRequest, ResponseObject = ModelState.ToJson() }.ToJsonResult()); } }
public void UpdateRawMaterial(UpdateRawMaterialInput input) { var rawmaterial = _RawMaterialRepository.Get(input.Id); rawmaterial.RawMaterialTypeId = input.RawMaterialTypeId; rawmaterial.BrandId = input.BrandId; rawmaterial.ProductName = input.ProductName; rawmaterial.Model = input.Model; rawmaterial.Size = input.Size; rawmaterial.Color = input.Color; rawmaterial.Origin = input.Origin; rawmaterial.ProductUnitId = input.ProductUnitId; rawmaterial.ReOrderPoint = input.ReOrderPoint; _RawMaterialRepository.Update(rawmaterial); }
public async Task <RawMaterial> Update(UpdateRawmaterial model) { return(await rawMaterialRepository.Update(model)); }