public ValidationData ValidateUpdateProductionBatch(ClaimsPrincipal principal,
                                                            ProductionBatch entity, UpdateProductionBatchModel model)
        {
            var validationData = new ValidationData();

            if (model.TotalAmount <= 0)
            {
                validationData.Fail("Invalid total amount", Constants.AppResultCode.FailValidation);
            }
            return(validationData);
        }
        public IActionResult Update(int id, UpdateProductionBatchModel model)
        {
            var entity = _service.ProductionBatchs.Id(id).FirstOrDefault();

            if (entity == null)
            {
                return(NotFound(AppResult.NotFound()));
            }
            var validationData = _service.ValidateUpdateProductionBatch(User, entity, model);

            if (!validationData.IsValid)
            {
                return(BadRequest(AppResult.FailValidation(data: validationData)));
            }
            _service.UpdateProductionBatch(entity, model);
            context.SaveChanges();
            // must be in transaction
            var ev = _ev_service.UpdateProductionBatch(entity, User);

            context.SaveChanges();
            return(NoContent());
        }
 public void UpdateProductionBatch(ProductionBatch entity, UpdateProductionBatchModel model)
 {
     model.CopyTo(entity);
     PrepareUpdate(entity);
 }