public static bool AddLogin(Login login)
 {
     lock (dcc)
     {
         var query = from dblogin in dcc.Logins where login.Name == dblogin.Name select login.LoginId;
         if (query.Count() == 0)
         {
             try
             {
                 dcc.Logins.Add(login);
                 dcc.SaveChanges();
                 return true;
             }
             catch (Exception) { }
         }
         return false; 
     }
 }
 public static List<Favorite> DownloadFavorites(Login login)
 {
     List<Favorite> favList = (from log1 in dcc.Logins where log1.Name == login.Name && log1.Password == login.Password select log1.Favorites).First();
     foreach (var favItem in favList)
     {
         favItem.FavoriteCompontents = new List<FavoriteComponent>();
         foreach (var CompItem in DownloadFavoriteComponents(favItem))
         {
             CompItem.Meal = DownloadMeal(CompItem);
             favItem.FavoriteCompontents.Add(CompItem);
         }
     }
     return favList;
 }
 public static int GetLoginId(Login login)
 {
     return (from log1 in dcc.Logins where log1.Name == login.Name && log1.Password == login.Password select log1.LoginId).First();
 }
 public static bool Login(Login login)
 {
     lock (dcc)
     {
         var query = from log1 in dcc.Logins where login.Name == log1.Name && log1.Password == login.Password select login.LoginId;
         if (query.Count() == 1)
         {
             return true;
         }
         return false; 
     }
 }
        public static List<Consumed> DownloadConsumed(Login login)
        {
            List<Consumed> consumedList = new List<Consumed>();
            foreach (var consumed in dcc.Consumeds)
            {
                if (GetFavorite(consumed).LoginId == GetLoginId(login))
                {
                    consumed.Favorite.FavoriteCompontents = DownloadFavoriteComponents(consumed.Favorite);
                    foreach (var component in consumed.Favorite.FavoriteCompontents)
                    {
                        component.Meal = DownloadMeal(component);
                    }
                    consumedList.Add(consumed);
                }
            }

            return consumedList;
        }
Ejemplo n.º 6
0
 public WcfLogin(Login login)
 {
     this.Name = login.Name;
     this.Password = login.Password;
 }