public static bool IsComplete(Category category)
 {
     if (HasName(category)
         && HasOrder(category))
         return true;
     return false;
 }
        public HttpResponseMessage Post(Category category)
        {
            if (category.Name == "")
                return Request.CreateResponse(HttpStatusCode.BadRequest, "A complete category model is required.");

            if (!CategoryServices.IsComplete(category))
                return Request.CreateResponse(HttpStatusCode.BadRequest);

            if (db.GetByName(category.Name) == null)
            {
                if(db.Insert(category))
                {
                    return Request.CreateResponse(HttpStatusCode.Created);
                }
            }
            if(db.Update(category))
                return Request.CreateResponse(HttpStatusCode.Accepted);
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
        private void SeedCategories()
        {
            for (int i = 0; i <= 4; i++ )
            {
                Category category = new Category();
                if(i == 0)
                    category.Name = "General";
                if (i == 1)
                    category.Name = "Worksheets";
                if (i == 2)
                    category.Name = "Time Management";
                if (i == 3)
                    category.Name = "Discipline";
                if (i == 4)
                    category.Name = "Montessori";
                categoryDB.Insert(category);
            }

            categoryDB.SaveChanges();
        }
        public HttpResponseMessage Seed()
        {
            if(db.GetAll().Count() >= 4)
                return Request.CreateResponse(HttpStatusCode.BadRequest, "Categories have already been created.");
            List<Category> categories = new List<Category>();
            for (int i = 1; i <= 5; i++)
            {
                Category category = new Category();
                category.ID = i;
                if (i == 1)
                    category.Name = "General";
                if (i == 2)
                    category.Name = "Interesting";
                if (i == 3)
                    category.Name = "Students";
                if (i == 4)
                    category.Name = "Homework";
                if (i == 5)
                    category.Name = "Stress";
                category.Order = i;
                category.URL = "/Category/" + category.Name;

                db.Insert(category);
            }
            if (db.SaveChanges() == 5)
                return Request.CreateResponse(HttpStatusCode.Created);
            return Request.CreateResponse(HttpStatusCode.InternalServerError, "An error occured while inserting data into the database.");
        }
 public static bool HasOrder(Category category)
 {
     if (category.Order == null)
         return false;
     return true;
 }
 public static bool HasName(Category category)
 {
     if (category.Name == null)
         return false;
     return true;
 }