public IHttpActionResult PutList(int id, ListModel list)
        {
            if (!ModelState.IsValid) //ModelState is an object that reads the object coming into the method, 
                                     //checks for any of the attributes and runs required validation
                                     // !ModelState means it's empty
            {
                // service-side validation
                return BadRequest(ModelState);
            }

            if (id != list.ListId)
            {
                return BadRequest();
            }

            var dbList = db.Lists.Find(id);

            // should only use automapping when making a model from an object, but not backwards
            dbList.Update(list);


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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            //put method is a one-way communication so it doesn't have to return anything
            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PutList(int id, ListModel list)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != list.ListId)
            {
                return BadRequest();
            }
            #region this need to be chagne

            //////////////////Below is the update part
            var dblist = db.Lists.Find(id);
            dblist.Update(list);
            db.Entry(dblist).State = EntityState.Modified;
            ////////////////////////////////////////////////////////////////
            //db.Entry(list).State = EntityState.Modified; ///this was the original code not a DTOs 
            #endregion
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ListExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public IHttpActionResult PostList(ListModel list)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var dbList = new List(list);

            db.Lists.Add(dbList);
            db.SaveChanges();

            list.CreatedDate = dbList.CreatedDate;
            list.ListId = dbList.ListId;

            // returns the object that is created 
            return CreatedAtRoute("DefaultApi", new { id = dbList.ListId }, list);
        }
        public IHttpActionResult PostList(ListModel list)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            //////////the New code
            var dblist = new List(list);


           //dblist.CreatedDate = DateTime.Now;
           list.CreatedDate =  dblist.CreatedDate; //those tow lines to show the user the old values with updated dates.
           list.ListId = dblist.ListId;

            db.Lists.Add(dblist);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = list.ListId }, list);
        }