Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public ActionResult Update([FromBody] ProductUnitViewModel productUnit)
        {
            var currentRes = _bo.Read(productUnit.Id);

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

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

            if (current.ProductModelId == productUnit.ProductModelId && current.SerialNumber == productUnit.SerialNumber)
            {
                return(StatusCode((int)HttpStatusCode.NotModified));
            }

            if (current.ProductModelId != productUnit.ProductModelId)
            {
                current.ProductModelId = productUnit.ProductModelId;
            }
            if (current.SerialNumber != productUnit.SerialNumber)
            {
                current.SerialNumber = productUnit.SerialNumber;
            }


            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }