public string ValorarOferta() { Core.DALC.QueOfrecesEntities db = new Core.DALC.QueOfrecesEntities(); Core.DALC.VALORACION valoracion = new Core.DALC.VALORACION(); Core.DALC.USUARIO user = new Core.DALC.USUARIO(); int puntos = ((int)db.USUARIO.Find(this.IdUsuario).PUNTOS) + 10; try { db.USUARIO.Find(this.IdUsuario).PUNTOS = puntos; valoracion.COMENTARIO = this.Comentario; valoracion.CALIFICACION = this.Calificacion.ToString(); valoracion.USUARIO_ID = this.IdUsuario; valoracion.OFERTA_ID = this.IdOferta; valoracion.RUBRO = this.Rubro.ToString(); valoracion.CODE_IMAGEN = this.codeImagen; valoracion.FECHA_VALORACION = DateTime.Now; db.VALORACION.Add(valoracion); db.SaveChanges(); this.response = "OK"; } catch (Exception) { this.response = "ERR"; } return(Serializar()); }
public string deshacerValoracion(string json) { DataContractJsonSerializer serializador = new DataContractJsonSerializer(typeof(FilterParameter)); MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json)); FilterParameter f = (FilterParameter)serializador.ReadObject(stream); Core.DALC.QueOfrecesEntities ctx = new Core.DALC.QueOfrecesEntities(); int IdValoracion = int.Parse(f.parameter); try { Core.DALC.VALORACION val = (Core.DALC.VALORACION)ctx.VALORACION.Where(b => b.ID_VALORACION == IdValoracion).First(); ctx.VALORACION.Remove(val); ctx.SaveChanges(); f.parameter = "OK"; } catch (Exception) { f.parameter = "NO"; } return(SerializarFilterParameterUnico(f)); }