public string Get([FromQuery] RequestClientComment req)//[FromUri] { //MobileAppSettingsDictionary settings = this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings(); //ITraceWriter traceWriter = this.Configuration.Services.GetTraceWriter(); string json = ""; string step_err = ""; try { if (req.id_shop != null) { step_err += "enter if = "; ResponseCommentClient resp = new ResponseCommentClient(); resp.GetCommentShop(Constants.connectDB, req.id_shop); step_err += "get comment = "; json = JsonConvert.SerializeObject(resp); step_err += "convert json = "; } } catch (Exception ex) { json = step_err + ex.Message; } return(json); }
// POST api/<controller> public string Post([FromBody] RequestClientComment req) { //ITraceWriter traceWriter = this.Configuration.Services.GetTraceWriter(); ResponseCommentClient resp = new ResponseCommentClient(); string json = ""; try { json = resp.SetCommentShop(Constants.connectDB, req); } catch (Exception ex) { json += ex.Message; } return("Спасибо за отзыв!"); }
public string SetCommentShop(string connectionString, RequestClientComment req) { if (req.id_shop == null || req.Comment == null || req.Email == null || req.Name == null || req.Count_star == 0 ) { return("Не все поля заполнены"); } string sqlExpression = @"INSERT INTO SPAVREMONT.Comment_Client ( ID_comment_client, ID_shop, ID_comment_shop, Email, Name, Comment, Count_star, Date_add, Visible, Deleted ) VALUES( '" + Guid.NewGuid().ToString() + @"', '" + req.id_shop + @"', NULL, '" + req.Email + @"', '" + req.Name + @"', '" + req.Comment + @"', " + req.Count_star.ToString() + @", Current_timestamp, 1, 0 ) "; //////////////////// //TEST для теста параметр Visible=1 //PROD данный параметр должен быть 0 ///одобрять комментарий могут владельцы магазинов //////////////////// int number = 0; SqlConnection connection = new SqlConnection(Constants.connectDB); connection.Open(); SqlCommand command = new SqlCommand(sqlExpression, connection); number = command.ExecuteNonQuery(); if (number > 0) { return(Constants.RESULT_OK); } else { return(Constants.RESULT_ERR); } }