public IActionResult Create([Bind("BatchId,Name,Variety,Quantity")] BatchModel batchemodel) { try { if (ModelState.IsValid) { _batchBll.AddUpdateBatchStock(batchemodel); return(RedirectToAction(nameof(Index))); } return(View(batchemodel)); } catch (Exception ex) { _logger.Error($"Something went wrong: {ex}"); return(RedirectToAction("Error", "Home")); } }
public void Can_Add_BatchesAndStock() { //Arrange int Id = 1; BatchModel batch = new BatchModel() { Name = "Product", Quantity = 20, Variety = "Variety", BatchId = 0 }; _mockRepository.Setup(m => m.AddUpdateBatchStock(batch.BatchId, batch.Quantity, batch.Name, batch.Variety)).Returns((int e) => { e = Id; return(e); }); //Act _service.AddUpdateBatchStock(batch); //Assert Assert.AreEqual("Product", batch.Name); }