public async Task <IHttpActionResult> DeleteHistory(int id)
        {
            History history = await db.Histories.FindAsync(id);

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

            //if requested history is not in a class the user owns
            if (!IdService.isValidHistoryId(id, db, User))
            {
                return(BadRequest("invalid history id for the given user"));
            }

            db.Histories.Remove(history);
            await db.SaveChangesAsync();

            return(Ok(history));
        }
        public async Task <IHttpActionResult> PutHistory(int id, [FromBody] History history)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if requested history is not in a class the user owns
            if (!IdService.isValidHistoryId(id, db, User))
            {
                return(BadRequest("invalid history id for the given user"));
            }

            if (id != history.Hist_Id)
            {
                return(BadRequest());
            }

            db.Entry(history).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.OK));
        }