Beispiel #1
0
        public ActionResult Update([FromBody] StoreQueueViewModel sq)
        {
            var currentResult = _bo.Read(sq.Id);

            if (!currentResult.Success)
            {
                return(InternalServerError());
            }
            var current = currentResult.Result;

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

            if (current.Quantity == sq.Quantity)
            {
                return(NotModified());
            }

            if (current.Quantity != sq.Quantity)
            {
                current.Quantity = sq.Quantity;
            }


            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(InternalServerError());
            }
            return(Ok());
        }
        public void TestUpdateStoreQueues()
        {
            ContextSeeder.Seed();
            var bo         = new StoreQueueBusinessObject();
            var resultList = bo.List();
            var item       = resultList.Result.FirstOrDefault();

            item.Quantity = 24;
            var resUpdate  = bo.Update(item);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().Quantity == 24);
        }
        public void TestUpdateStoreQueue()
        {
            ContextSeeder.Seed();
            var bo       = new StoreQueueBusinessObject();
            var stoQList = bo.List();
            var item     = stoQList.Result.FirstOrDefault();

            item.Quantity = 10;
            var stoQUpdate  = bo.Update(item);
            var stoQNotList = bo.ListNotDeleted().Result;

            Assert.IsTrue(stoQUpdate.Success && stoQNotList.First().Quantity == 10);
        }
        public ActionResult Update([FromBody] StoreQueueViewModel storeQueue)
        {
            var currentRes = _bo.Read(storeQueue.Id);
            if (!currentRes.Success) return StatusCode((int)HttpStatusCode.InternalServerError);
            var current = currentRes.Result;
            if (current == null) return NotFound();

            if (current.EstablishmentId == storeQueue.EstablishmentId && current.Quantity == storeQueue.Quantity)
                return StatusCode((int)HttpStatusCode.NotModified);

            if (current.EstablishmentId != storeQueue.EstablishmentId) current.EstablishmentId = storeQueue.EstablishmentId;
            if (current.Quantity != storeQueue.Quantity) current.Quantity = storeQueue.Quantity;


            var updateResult = _bo.Update(current);
            if (!updateResult.Success) return StatusCode((int)HttpStatusCode.InternalServerError);
            return Ok();
        }