public static List <AudioTierRating> GetRatings()
        {
            ISession session            = SessionManager.GetSession();
            List <AudioTierRating> list = new List <AudioTierRating>();


            if (session == null)
            {
                return(null);
            }

            var ratings = session.Execute("select * from \"AudioTierRating\"");


            foreach (var data in ratings)
            {
                AudioTierRating rate = new AudioTierRating();
                rate.description      = data["description"] != null ? data["description"].ToString() : string.Empty;
                rate.evaluation       = (double)(data["evaluation"] != null ? data["evaluation"] : 0);
                rate.customer_name    = data["customer_name"] != null ? data["customer_name"].ToString() : string.Empty;
                rate.customer_surname = data["customer_surname"] != null ? data["customer_surname"].ToString() : string.Empty;
                rate.customer_email   = data["customer_email"] != null ? data["customer_email"].ToString() : string.Empty;
                rate.platform         = data["platform"] != null ? data["platform"].ToString() : string.Empty;
                list.Add(rate);
            }
            return(list);
        }
        public static void AddRate(AudioTierRating rate)
        {
            ISession session = SessionManager.GetSession();

            if (session == null)
            {
                return;
            }

            RowSet data = session.Execute("insert into \"AudioTierRating\" (description,evaluation,customer_name,customer_surname,customer_email,platform) values ('" + rate.description + "'," + rate.evaluation + ",'" + rate.customer_name + "','" + rate.customer_surname + "','" + rate.customer_email + "','" + rate.platform + "')");
        }
Exemplo n.º 3
0
        private void btnSubmit_Click_1(object sender, EventArgs e)
        {
            AudioTierRating atr = new AudioTierRating();

            atr.description      = tbDescription.Text;
            atr.evaluation       = Double.Parse(tbEvaluation.Text);
            atr.platform         = audioPlatform;
            atr.customer_email   = customer.email;
            atr.customer_name    = customer.name;
            atr.customer_surname = customer.surname;
            DataProvider.AddRate(atr);

            this.Hide();
        }
        public static AudioTierRating GetAudioTierRating(string desc, string email)
        {
            ISession        session = SessionManager.GetSession();
            AudioTierRating rate    = new AudioTierRating();

            if (session == null)
            {
                return(null);
            }

            Row data = session.Execute("select * from \"AudioTierRaiting\" where description='" + desc + "' and customer_email='" + email + "'").FirstOrDefault();

            if (data != null)
            {
                rate.description      = data["description"] != null ? data["description"].ToString() : string.Empty;
                rate.evaluation       = (double)(data["evaluation"] != null ? data["evaluation"] :0);
                rate.customer_name    = data["customer_name"] != null ? data["customer_name"].ToString() : string.Empty;
                rate.customer_surname = data["customer_surname"] != null ? data["customer_surname"].ToString() : string.Empty;
                rate.customer_email   = data["customer_email"] != null ? data["customer_email"].ToString() : string.Empty;
                rate.platform         = data["platform"] != null ? data["platform"].ToString() : string.Empty;
            }

            return(rate);
        }