public bool LoginCustomer(string userName, string loginPassword)
 {
     try
     {
         using (var dbContext = new SampleCustomerInformationEntities())
         {
             CustomerInformation customer = new CustomerInformation();
             customer = dbContext.CustomerInformations.FirstOrDefault(x => x.User_Name == userName && x.Password == loginPassword);
             if (customer != null)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 2
0
 public bool RegisterCustomer(string firstName, string lastName, string email, string phoneNumber, string password)
 {
     try
     {
         using (var dbContext = new SampleCustomerInformationEntities())
         {
             CustomerInformation newCustomer = new CustomerInformation();
             newCustomer.CustomerID = dbContext.CustomerInformations.Count() + 1;
             newCustomer.First_Name = firstName;
             newCustomer.Last_Name  = lastName;
             newCustomer.Email      = email;
             newCustomer.Phone      = phoneNumber;
             newCustomer.Password   = password;
             newCustomer.User_Name  = email;
             dbContext.CustomerInformations.Add(newCustomer);
             dbContext.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }