Esempio n. 1
0
        public ActionResult Update([FromBody] CategoryInterestPointViewModel c)
        {
            var currentResult = _bo.Read(c.Id);

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

            if (current == null)
            {
                return(NotFound());
            }
            if (current.Name == c.Name)
            {
                return(new ObjectResult(HttpStatusCode.NotModified));
            }

            if (current.Name != c.Name)
            {
                current.Name = c.Name;
            }
            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
        public void TestUpdatetCategoryInterestPoint()
        {
            BoraNowSeeder.Seed();
            var cipbo   = new CategoryInterestPointBusinessObject();
            var resList = cipbo.List();
            var item    = resList.Result.FirstOrDefault();


            var categoryInterestPoint = new CategoryInterestPoint("C");

            item.Name = categoryInterestPoint.Name;
            var resUpdate = cipbo.Update(item);

            resList = cipbo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Name == categoryInterestPoint.Name);
        }