//Register Customer
 public string RegisterCustomer(string phoneno, string email, string fname, string lname, string password)
 {
     using (rideshareEntities entities = new rideshareEntities())
     {
         var a = entities.tbl_customer.SingleOrDefault(customer => customer.cus_phoneno == phoneno);
         if (a != null)
         {
             return(string.Format("Email Already Exist"));
         }
         else
         {
             tbl_customer customer = new tbl_customer {
                 cus_phoneno = phoneno, cus_password = password, cus_fname = fname, cus_lname = lname, cus_email = email
             };
             entities.tbl_customer.Add(customer);
             entities.SaveChanges();
             return(null);
         }
     }
 }
Exemplo n.º 2
0
        //public int Login(string username, string password)
        //{
        //    using (rideshareEntities entities = new rideshareEntities())
        //    {

        //        var isprecent = entities.tbl_customer.SingleOrDefault(customer => customer.cus_email == username && customer.cus_password == password);
        //        //var query = entities.tbl_customer.Where(p => p.cus_email == 'a' && p.product_price > 500 && p.product_price < 10000)
        //       // var queary = entities.tbl_customer.SingleOrDefault(customer => customer.cus_email == username && customer.cus_password == password);


        //        if (isprecent != null)
        //        {
        //            return 1;
        //        }
        //        else
        //        {
        //            return 0;
        //        }
        //    }



        //}

        //Register Customer
        public List <RegisterStatus> RegisterCustomer(string phoneno, string email, string fname, string lname, string password)
        {
            var registerstatus = new List <RegisterStatus>();

            using (rideshareEntities entities = new rideshareEntities())
            {
                var a = (from c in entities.tbl_customer where (c.cus_email == email || c.cus_phoneno == phoneno)select 1);
                //var a = entities.tbl_customer.SingleOrDefault(customer => customer.cus_phoneno == phoneno);

                var firstOrDefault = a.FirstOrDefault();
                if (firstOrDefault == 1)
                {
                    if (a != null)
                    {
                        registerstatus.Add(new RegisterStatus()
                        {
                            registration = "0"
                        });
                        return(registerstatus);;
                    }
                    return(registerstatus);;
                }



                else
                {
                    tbl_customer customer = new tbl_customer {
                        cus_phoneno = phoneno, cus_password = password, cus_fname = fname, cus_lname = lname, cus_email = email
                    };
                    entities.tbl_customer.Add(customer);
                    entities.SaveChanges();
                    registerstatus.Add(new RegisterStatus()
                    {
                        registration = "1"
                    });
                    return(registerstatus);;
                }
            }
        }
Exemplo n.º 3
0
        //public int Login(string username, string password)
        //{
        //    using (rideshareEntities entities = new rideshareEntities())
        //    {
        //        var isprecent = entities.tbl_customer.SingleOrDefault(customer => customer.cus_email == username && customer.cus_password == password);
        //        //var query = entities.tbl_customer.Where(p => p.cus_email == 'a' && p.product_price > 500 && p.product_price < 10000)
        //       // var queary = entities.tbl_customer.SingleOrDefault(customer => customer.cus_email == username && customer.cus_password == password);
        //        if (isprecent != null)
        //        {
        //            return 1;
        //        }
        //        else
        //        {
        //            return 0;
        //        }
        //    }
        //}
        //Register Customer
        public List<RegisterStatus> RegisterCustomer(string phoneno, string email, string fname, string lname, string password)
        {
            var registerstatus = new List<RegisterStatus>();
            using (rideshareEntities entities = new rideshareEntities())
            {
                var a = (from c in entities.tbl_customer where (c.cus_email == email || c.cus_phoneno== phoneno) select 1);
                //var a = entities.tbl_customer.SingleOrDefault(customer => customer.cus_phoneno == phoneno);

                var firstOrDefault = a.FirstOrDefault();
                if (firstOrDefault == 1  )
                {
                    if (a != null)
                    {
                        registerstatus.Add(new RegisterStatus()
                        {
                            registration = "0"

                        });
                        return registerstatus; ;

                    }
                    return registerstatus; ;
                }

                else
                {
                    tbl_customer customer = new tbl_customer { cus_phoneno = phoneno, cus_password = password, cus_fname = fname, cus_lname = lname, cus_email = email };
                    entities.tbl_customer.Add(customer);
                    entities.SaveChanges();
                    registerstatus.Add(new RegisterStatus()
                    {
                        registration = "1"

                    });
                    return registerstatus; ;
                }

            }
        }