public bool CreateCustomerRating(CustomerRatingCreate model)
        {
            var entity =
                new CustomerRating()
            {
                FKCustomerID = model.CustomerId,
                Timeliness   = model.Timeliness,
                Care         = model.Care,
                Ease         = model.Ease
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.CustomerRatings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
예제 #2
0
        //Post a Customer Rating
        /// <summary>
        /// Post new CustomerRating to the Database
        /// </summary>
        /// <param name="customerRating">Contains the required fields for a CustomerRating object</param>
        /// <returns></returns>
        public IHttpActionResult Post(CustomerRatingCreate customerRating)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service =
                CreateCustomerRatingService();

            if (!service.CreateCustomerRating(customerRating))
            {
                return(InternalServerError());
            }

            return(Ok());
        }