public HttpResponseMessage GetOneFeedback(int id)
 {
     try
     {
         UserFeedbackModel userFeedback = logic.GetOneFeedback(id);
         return(Request.CreateResponse(HttpStatusCode.OK, userFeedback));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
Beispiel #2
0
        public UserFeedbackModel AddFeedback(UserFeedbackModel userFeedbackModel)
        {
            UsersFeedback userFeedback = new UsersFeedback
            {
                UserID       = userFeedbackModel.userID,
                FeedbackDate = userFeedbackModel.feedbackDate,
                FeedbackText = userFeedbackModel.feedbackText
            };

            DB.UsersFeedbacks.Add(userFeedback);
            DB.SaveChanges();

            userFeedbackModel.feedbackID = userFeedback.FeedbackID;
            return(GetOneFeedback(userFeedback.FeedbackID));
        }
        public HttpResponseMessage AddFeedback(UserFeedbackModel userFeedbackModel)
        {
            try
            {
                // אם הולידציה נכשלה:
                if (!ModelState.IsValid)
                {
                    List <PropErrors> errorList = ErrorExtractor.ExtractErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errorList));
                }

                UserFeedbackModel userFeedback = logic.AddFeedback(userFeedbackModel);
                return(Request.CreateResponse(HttpStatusCode.Created, userFeedback));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }