public StorageImport Create(StorageImport request) { var storageImport = _repository.Add(request); _repository.Save(); return(storageImport); }
public IActionResult Create([FromBody] StorageImport request) { var actionResult = new CustomActionResult { Successful = true, Message = "Storage Import was successfull created!" }; try { request.SetAudit(CurrentLoggedUserId); var storageImport = _storageImportService.Create(request); actionResult.EntityId = storageImport.Id; } catch { actionResult.Successful = false; actionResult.Message = "Create storage import was unsuccessfully, please try again!"; return(Ok(actionResult)); } try { var product = _productService.GetById(request.ProductId); product.StorageQuantity += request.Quantity; product.SetAudit(CurrentLoggedUserId); _productService.Update(product); } catch { actionResult.Successful = false; actionResult.Message = "Create storage import was successfully, but Storage Quantity of the product was not updated properly, please contact Office worker!"; return(Ok(actionResult)); } return(Ok(actionResult)); }