public bool registerGrades(ReviewsModel model) { model.totalGrade = fetchMerits(model.email) * (model.generalOpinion + model.communityContribution + model.articleStructure); SqlCommand cmd = conn.setSimpleReturnQuery("UPDATE Reviews " + "SET comments = @comments, " + " generalOpinion = @generalOpinion, " + " communityContribution = @communityContribution, " + " articleStructure = @articleStructure, " + " totalGrade = @totalGrade, " + " state = @state " + "WHERE articleId = @articleId " + "AND email = @email"); cmd.Parameters.AddWithValue("@comments", model.comments); cmd.Parameters.AddWithValue("@generalOpinion", model.generalOpinion); cmd.Parameters.AddWithValue("@communityContribution", model.communityContribution); cmd.Parameters.AddWithValue("@articleStructure", model.articleStructure); cmd.Parameters.AddWithValue("@totalGrade", model.totalGrade); cmd.Parameters.AddWithValue("@state", "reviewed"); cmd.Parameters.AddWithValue("@articleId", model.articleId); cmd.Parameters.AddWithValue("@email", model.email); conn.conn.Open(); cmd.ExecuteNonQuery(); conn.conn.Close(); return(true); }
// Se agrega un nuevo articulo public bool AddReview(ReviewsModel smodel) { connection(); string AddNewArticle = "INSERT INTO REVIEWS " + "VALUES (@articleId, @email, @comments ,@generalOpinion ,@communityContribution,@articleStructure,@totalGrade,@state)"; SqlCommand cmd = new SqlCommand(AddNewArticle, con); // Nombre procedimiento, cmd.Parameters.AddWithValue("@articleId", smodel.articleId); cmd.Parameters.AddWithValue("@email", smodel.email); cmd.Parameters.AddWithValue("@comments", smodel.comments); cmd.Parameters.AddWithValue("@generalOpinion", smodel.generalOpinion); cmd.Parameters.AddWithValue("@communityContribution", smodel.communityContribution); cmd.Parameters.AddWithValue("@articleStructure", smodel.communityContribution); cmd.Parameters.AddWithValue("@articleStructure", smodel.articleStructure); cmd.Parameters.AddWithValue("@totalGrade", smodel.totalGrade); cmd.Parameters.AddWithValue("@state", smodel.state); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }