public IActionResult ReplyToFeedback(ReplyReq req) { BaseResponse resp = new BaseResponse(); try { if (RequestValidator.ReplyToFeedback(req)) { if (req.user_id == JwtToken.GetUserID(req.token)) { if (!FeedbackCRUD.IsALreadyRepliedToFeedback(req.feedback_id, req.user_id)) { var dbReq = new FeedbackChats() { FeedbackId = req.feedback_id, Reply = req.reply, LastUpdate = DateTime.Now, ReplyGivenBy = req.user_id }; FeedbackCRUD.ReplyToFeedback(dbReq); resp.status_code = Ok().StatusCode; resp.status_message = StatusMessage.Success; } else { resp = new BaseResponse() { status_code = 201, status_message = StatusMessage.RepliedAlready }; } } else { resp.status_code = Unauthorized().StatusCode; resp.status_message = StatusMessage.UnAuthorised; } } else { resp.status_code = BadRequest().StatusCode; resp.status_message = StatusMessage.BadRequest; } } catch (Exception es) { resp.status_code = 500; resp.status_message = StatusMessage.InternalServerError; } return(Ok(resp)); }
internal static bool ReplyToFeedback(ReplyReq req) { if (req == null || string.IsNullOrEmpty(req.device_id) || string.IsNullOrEmpty(req.os_type) || req.user_id <= 0) { return(false); } else { return(true); } }