Example #1
0
        public ActionResult Update([FromBody] ShoppingBasketViewModel shoppingBasket)
        {
            var currentRes = _bo.Read(shoppingBasket.Id);

            if (!currentRes.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            var current = currentRes.Result;

            if (current == null)
            {
                return(NotFound());
            }

            if (current.ProfileId == shoppingBasket.ProfileId)
            {
                return(StatusCode((int)HttpStatusCode.NotModified));
            }

            if (current.ProfileId != shoppingBasket.ProfileId)
            {
                current.ProfileId = shoppingBasket.ProfileId;
            }


            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
Example #2
0
        public void TestUpdateShoppingBasket()
        {
            ContextSeeder.Seed();
            var bo      = new ShoppingBasketBusinessObject();
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();
            var pbo     = new ProfileBusinessObject();
            var pro     = pbo.List().Result.FirstOrDefault();

            item.ProfileId = pro.Id;
            var resUpdate  = bo.Update(item);
            var resNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().ProfileId == pro.Id);
        }
        public void TestUpdateShoppingBasket()
        {
            ContextSeeder.Seed();
            var bo  = new ShoppingBasketBusinessObject();
            var ebo = new EstablishmentBusinessObject();
            var rbo = new RegionBusinessObject();
            var cbo = new CompanyBusinessObject();
            var reg = rbo.List().Result.FirstOrDefault();
            var com = cbo.List().Result.FirstOrDefault();
            var est = new Establishment("rua das papoilas", "09h00", "20h00", "sundays and holidays", reg.Id, com.Id);

            ebo.Create(est);
            var resList = bo.List();
            var item    = resList.Result.FirstOrDefault();

            item.EstablishmentId = est.Id;
            var resUpdate  = bo.Update(item);
            var resNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(resUpdate.Success && resNotList.First().EstablishmentId == est.Id);
        }