public ActionResult Create([FromBody] ProductUnitViewModel vm) { var productUnit = vm.ToModel(); var res = _bo.Create(productUnit); return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError)); }
public void TestCreateSameSerialNumberProductUnit() { 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.List().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.Create(prodUnit); Assert.IsTrue(!resCreate.Result); }
public void TestCreateAndReadProductUnit() { ContextSeeder.Seed(); var pmbo = new ProductModelBusinessObject(); var prodMod = pmbo.ListNotDeleted().Result.First(); var ebo = new EstablishmentBusinessObject(); var est = ebo.ListNotDeleted().Result.First(); var sbo = new ShoppingBasketBusinessObject(); var sbk = sbo.ListNotDeleted().Result.First(); var bo = new ProductUnitBusinessObject(); var prodUnit = new ProductUnit("werkyt235", false, prodMod.Id, est.Id, sbk.Id); var resCreate = bo.Create(prodUnit); var resGet = bo.Read(prodUnit.Id); Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }