示例#1
0
    public bool Register(string username, string password, string email, string number)
    {
        bool result = false;

        using (SGEntities context = new SGEntities())
        {
            try
            {
                User_statistics user_statistics = new User_statistics();
                context.User_statistics.Add(user_statistics);

                User_info user_info = new User_info(email, number);
                context.User_info.Add(user_info);

                User user = new User(username, password);
                user.user_info       = user_info.id;
                user.user_statistics = user_statistics.id;
                context.Users.Add(user);

                context.SaveChanges();
                result = true;
            }
            catch (Exception) { }
        }
        return(result);
    }
示例#2
0
 public Price[] GetPrices(string name)
 {
     using (SGEntities context = new SGEntities())
     {
         var prices = (from i in context.Items
                       where i.label == name
                       select i.Prices).Single();
         return(prices.ToArray());
     }
 }
示例#3
0
 public bool Login(string username, string password)
 {
     using (SGEntities context = new SGEntities())
     {
         return((from u in context.Users
                 where u.username == username &&
                 u.password == password
                 select u).Any <User>());
     }
 }
示例#4
0
 public Price GetPrice(string name, string shop)
 {
     using (SGEntities context = new SGEntities())
     {
         try
         {
             var prices = (from i in context.Items
                           where i.label == name
                           select i.Prices).Single();
             return((from p in prices
                     where p.shop == shop
                     select p).Single());
         }
         catch (Exception)
         {
             return(null);
         }
     }
 }