Esempio n. 1
0
        public IHttpActionResult Put(CategoryBTO categBto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            CategoryLogic categ         = new CategoryLogic();
            var           existingCateg = categ.Retrieve(categBto.Id);

            if (existingCateg != null)
            {
                categ.Update(categBto);
            }
            else
            {
                return(NotFound());
            }

            return(Ok());
        }
Esempio n. 2
0
        public IHttpActionResult GetById(int idParent)
        {
            //using (CategoryRepo repo = new CategoryRepo(context))
            //{
            //    //De la Logique...
            //    var obj = repo.Retrieve(idParent);

            //    //return Ok(JsonConvert.SerializeObject(obj, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })) ;

            //    //var temp = JsonConvert.SerializeObject(obj,
            //    //    Formatting.Indented,
            //    //    new JsonSerializerSettings()
            //    //    {
            //    //        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            //    //    });

            //    var Response = obj.CategoryToCategoryBTO();
            //    Response.Children = repo.RetrieveChildren(idParent)
            //        .Select(x => x.CategoryToCategoryBTO()).ToList();

            CategoryLogic categ = new CategoryLogic();

            return(Ok(categ.Retrieve(idParent)));
        }