Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }