public ActionResult Create([FromBody] BrandViewModel vm)
        {
            var brand = vm.ToModel();
            var res   = _bo.Create(brand);

            return(StatusCode(res.Success ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void TestCreateAndReadBrand()
        {
            ContextSeeder.Seed();
            var bo        = new BrandBusinessObject();
            var reg       = new Brand("Dona Ermelinda");
            var resCreate = bo.Create(reg);
            var resGet    = bo.Read(reg.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Esempio n. 4
0
        public void TestCreateSameNameBrand()
        {
            ContextSeeder.Seed();
            var bo        = new BrandBusinessObject();
            var item      = bo.List().Result.FirstOrDefault();
            var reg       = new Brand(item.Name);
            var resCreate = bo.Create(reg);

            Assert.IsTrue(!resCreate.Result);
        }
Esempio n. 5
0
        public void TestUpdateSameNameBrandAsync()
        {
            ContextSeeder.Seed();
            var bo   = new BrandBusinessObject();
            var item = new Brand("Dona Ermelinda");

            bo.Create(item);
            item.Name = "Dona Edite";
            var resUpdate = bo.UpdateAsync(item).Result;

            Assert.IsTrue(!resUpdate.Result);
        }