Ejemplo n.º 1
0
        public IHttpActionResult PutCategory(string Code, category_dict Category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Code != Category.Code)
            {
                return(BadRequest());
            }

            Db.Entry(Category).State = EntityState.Modified;

            try
            {
                Db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryExists(Code))
                {
                    return(NotFound());
                }
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetCategory(string Code)
        {
            category_dict categoryDict = Db.category_dict.AsEnumerable().FirstOrDefault(X => X.Code == Code);

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

            return(Ok(categoryDict));
        }
Ejemplo n.º 3
0
        public IHttpActionResult DeleteCategory(string Code)
        {
            category_dict categoryDict = Db.category_dict.AsEnumerable().FirstOrDefault(X => X.Code == Code);

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

            Db.category_dict.Remove(categoryDict);
            Db.SaveChanges();

            return(Ok(categoryDict));
        }
Ejemplo n.º 4
0
        public IHttpActionResult PostCategory(category_dict Category)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Db.category_dict.Add(Category);

            try
            {
                Db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CategoryExists(Category.Code))
                {
                    return(Conflict());
                }
                throw;
            }

            return(CreatedAtRoute("DefaultApi", new { id = Category.ID }, Category));
        }