// Post a Tool Rating
        /// <summary>
        /// Post a new ToolRating to the Database
        /// </summary>
        /// <param name="ToolRating">Contains the required fields for a ToolRating object</param>
        /// <returns></returns>
        public IHttpActionResult Post(ToolRatingCreate ToolRating)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateToolRatingService();

            if (!service.CreateToolRating(ToolRating))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 2
0
        //
        // Tool Rating Methods
        //

        public bool CreateToolRating(ToolRatingCreate model)
        {
            var entity =
                new ToolRating()
            {
                FKToolID  = model.ToolID,
                Accuracy  = model.Accuracy,
                Condition = model.Condition,
                Usability = model.Usability
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.ToolRatings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }