public ActionResult Create([FromBody] ProductModelViewModel vm) { var productModel = vm.ToModel(); var res = _bo.Create(productModel); return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError)); }
public void TestCreateSameSerialNumberProductUnitAsync() { ContextSeeder.Seed(); var braBo = new BrandBusinessObject(); var bra = new Brand("Barraca do Tejo"); braBo.Create(bra); var catBo = new CategoryBusinessObject(); var cat = new Category("Non-Alcoholic Beverages"); catBo.Create(cat); var pmbo = new ProductModelBusinessObject(); var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id); pmbo.Create(prodMod); var sbo = new ShoppingBasketBusinessObject(); var sbk = sbo.ListNotDeleted().Result.First(); var bo = new ProductUnitBusinessObject(); var item = bo.ListAsync().Result.Result.FirstOrDefault(); var ebo = new EstablishmentBusinessObject(); var est = ebo.ListNotDeleted().Result.First(); var prodUnit = new ProductUnit(item.SerialNumber, false, prodMod.Id, est.Id, sbk.Id); var resCreate = bo.CreateAsync(prodUnit).Result; Assert.IsTrue(!resCreate.Result); }
public void TestCreateSameBarCodeProductModel() { ContextSeeder.Seed(); var braBo = new BrandBusinessObject(); var bra = braBo.ListNotDeleted().Result.First(); var catBo = new CategoryBusinessObject(); var cat = catBo.ListNotDeleted().Result.First(); var bo = new ProductModelBusinessObject(); var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id); var resCreate = bo.Create(prodMod); Assert.IsTrue(!resCreate.Result); }
public void TestCreateAndReadProductModel() { ContextSeeder.Seed(); var braBo = new BrandBusinessObject(); var bra = braBo.ListNotDeleted().Result.First(); var catBo = new CategoryBusinessObject(); var cat = catBo.ListNotDeleted().Result.First(); var bo = new ProductModelBusinessObject(); var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id); var resCreate = bo.Create(prodMod); var resGet = bo.Read(prodMod.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }