Example #1
0
//        public List<CompanyRecords> myproduct(classviewmodel cv)
        public bool myproduct(classviewmodel cv)
        {
            using (MySqlConnection conn = GetConnection())
            {
                conn.Open();
                var            id      = cv.usernm[0].id;
                CompanyRecords results = conn.Query <CompanyRecords>("select * from product where user_id='" + id + "'").FirstOrDefault();
                //List<CompanyRecords> result = conn.Query<CompanyRecords>("select count(*) from product where user_id='" + id + "'").ToList();
                if (results != null)
                {
                    return(true);
                }
                return(false);
                //return results;
            }
        }
Example #2
0
        public bool updateproduct(CompanyRecords cr, classviewmodel cv)
        {
            using (MySqlConnection conn = GetConnection())
            {
                conn.Open();
                var id     = cr.id;
                var userid = cv.usernm[0].id;
                cr.user_id = userid;
                //string query = "update product set(user_id, product_name, Keywords, category, description, modules, metatags, geographical_focus, target_job_titles, target_industry_type, desktop_web_both, dept_user_type, semantic, cognitive, pricing, status) " +
                //                                             " values(@user_id,@product_name,@Keywords,@category,@description,@modules,@metatags,@geographical_focus,@target_job_titles,@target_industry_type,@desktop_web_both,@dept_user_type,@semantic,@cognitive,@pricing,@status)where id='" + id + "'";

                string query = "update product set product_name='" + cr.product_name + "', Keywords='" + cr.Keywords + "', category='" + cr.category + "', description='" + cr.description + "', modules='" + cr.modules + "' where id='" + id + "'";

                var results = conn.Execute(query, new
                {
                    cr.user_id,
                    cr.product_name,
                    cr.Keywords,
                    cr.category,
                    cr.description,
                    cr.modules,
                    cr.metatags,
                    cr.geographical_focus,
                    cr.target_job_titles,
                    cr.target_industry_type,
                    cr.desktop_web_both,
                    cr.dept_user_type,
                    cr.semantic,
                    cr.cognitive,
                    cr.pricing,
                    cr.status
                });
                //var results = conn.Execute("update product set [email protected]_name where id='"+id+"'");
                if (results > 0)
                {
                    return(true);
                }
                return(false);
            }
        }
Example #3
0
 //public List<CompanyRecords> myproduct(classviewmodel cv)
 ////public bool myproduct(classviewmodel cv)
 //{
 //    using (MySqlConnection conn = GetConnection())
 //    {
 //        conn.Open();
 //        var id = cv.usernm[0].id;
 //        //CompanyRecords results = conn.Query<CompanyRecords>("select * from product where user_id='" + id + "'").FirstOrDefault();
 //        //List<CompanyRecords> result = conn.Query<CompanyRecords>("select count(*) from product where user_id='" + id + "'").ToList();
 //        List<CompanyRecords> result = conn.Query<CompanyRecords>("select * from product where user_id='" + id + "'").ToList();
 //        if (result != null)
 //        {
 //            return result;
 //        }
 //        return result;
 //        //return results;
 //    }
 //}
 //Save products
 public bool SaveProduct(CompanyRecords cr, classviewmodel cv)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         var id = cv.usernm[0].id;
         cr.user_id = id;
         List <User>    resultmenu = new List <User>();
         CompanyRecords a          = conn.Query <CompanyRecords>("SELECT * FROM product where user_id ='" + id + "' ").FirstOrDefault();
         //User a = conn.Query<User>("select * from user");
         //var usernm = HttpContext.Session.GetString("username");
         //User a = conn.Query<User>("select * from User where username='******' ");
         //var usernm = cv.user;
         if (a != null)
         {
             cr.status = true;
             string query = "Insert into product(user_id, product_name, Keywords, category, description, modules, features, metatags, geographical_focus, target_job_titles, target_industry_type, desktop_web_both, dept_user_type, semantic, cognitive, pricing, status) " +
                            " values( @user_id,@product_name,@Keywords,@category,@description,@modules,@features,@metatags,@geographical_focus,@target_job_titles,@target_industry_type,@desktop_web_both,@dept_user_type,@semantic,@cognitive,@pricing,@status)";
             var results = conn.Execute(query, new
             {
                 cr.user_id,
                 cr.product_name,
                 cr.Keywords,
                 cr.category,
                 cr.description,
                 cr.modules,
                 cr.features,
                 cr.metatags,
                 cr.geographical_focus,
                 cr.target_job_titles,
                 cr.target_industry_type,
                 cr.desktop_web_both,
                 cr.dept_user_type,
                 cr.semantic,
                 cr.cognitive,
                 cr.pricing,
                 cr.status
             });
             if (results > 0)
             {
                 return(true);
             }
         }
         else
         {
             cr.status = false;
             string query = "Insert into product(user_id, product_name, Keywords, category, description, modules, features, metatags, geographical_focus, target_job_titles, target_industry_type, target_campany_size, desktop_web_both, dept_user_type, semantic, cognitive, pricing, status) " +
                            " values( @user_id,@product_name,@Keywords,@category,@description,@modules,@features,@metatags,@geographical_focus,@target_job_titles,@target_industry_type, @target_campany_size, @desktop_web_both, @dept_user_type, @semantic, @cognitive, @pricing, @status)";
             var results = conn.Execute(query, new
             {
                 cr.user_id,
                 cr.product_name,
                 cr.Keywords,
                 cr.category,
                 cr.description,
                 cr.modules,
                 cr.features,
                 cr.metatags,
                 cr.geographical_focus,
                 cr.target_job_titles,
                 cr.target_industry_type,
                 cr.target_campany_size,
                 cr.desktop_web_both,
                 cr.dept_user_type,
                 cr.semantic,
                 cr.cognitive,
                 cr.pricing,
                 cr.status
             });
             var results2 = conn.Execute("update user set role_id=5 where id='" + id + "'");
             //sendproductdetails(cr);
             if (results > 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }