Beispiel #1
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);
        }
Beispiel #2
0
        public void TestListProductUnit()
        {
            ContextSeeder.Seed();
            var bo      = new ProductUnitBusinessObject();
            var resList = bo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
Beispiel #3
0
        public void TestUpdateProductUnit()
        {
            ContextSeeder.Seed();
            var bo      = new ProductUnitBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.IsReserved = true;
            var resUpdate  = bo.Update(item);
            var resNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().IsReserved == true);
        }
Beispiel #4
0
        public ActionResult <List <ProductUnitViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            var list = new List <ProductUnitViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(new ProductUnitViewModel {
                    Id = item.Id, ProductModelId = item.ProductModelId, SerialNumber = item.SerialNumber
                });
            }
            return(list);
        }