public IHttpActionResult SubmitBug(SubmitBugInputModel model)
        {
            if (model == null || !this.ModelState.IsValid)
            {
                return this.BadRequest("You must submit bug title.");
            }

            var newBug = new Bug
            {
                Title = model.Title,
                Description = model.Description,
                DateCreated = DateTime.Now,
                Status = BugStatus.Open,
                UserId = this.User.Identity.GetUserId()
            };

            this.Data.Bugs.Add(newBug);
            this.Data.SaveChanges();

            object infoToReturn = new { newBug.Id, Message = "Anonymous bug submitted." };
            if (newBug.UserId != null)
            {
                infoToReturn = new
                {
                    newBug.Id, 
                    Author = this.User.Identity.GetUserName(), 
                    Message = "User bug submitted."
                };
            }

            return this.CreatedAtRoute(
                "DefaultApi",
                new { controller = "bugs", id = newBug.Id },
                infoToReturn);
        }
        public IHttpActionResult SubmitBug(SubmitBugInputModel bugData)
        {
            if (bugData == null)
            {
                return BadRequest("Missing bug data.");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var currentUserId = User.Identity.GetUserId();

            var bug = new Bug()
            {
                Title = bugData.Title,
                Description = bugData.Description,
                Status = BugStatus.Open,
                AuthorId = currentUserId,
                DateCreated = DateTime.Now
            };
            db.Bugs.Add(bug);
            db.SaveChanges();

            if (currentUserId != null)
            {
                return this.CreatedAtRoute(
                    "DefaultApi",
                    new { id = bug.Id },
                    new { bug.Id, Author = User.Identity.GetUserName(), Message = "User bug submitted." });
            }

            return this.CreatedAtRoute(
                "DefaultApi", 
                new { id = bug.Id },
                new { bug.Id, Message = "Anonymous bug submitted." });
        }