Example #1
0
        public List <YemekList> GetFood(string Ref)
        {
            EruWebServisClient client    = new EruWebServisClient();
            ResponseObject     response  = client.YemekList();
            List <YemekList>   yemekList = new List <YemekList>();
            List <YemekModel>  list      = ((YemekModel[])response.DataObject).ToList();

            foreach (var yemek in list)
            {
                YemekList yeniYemek = new YemekList();
                yeniYemek.Tarih    = yemek.date.Split(' ')[0].Replace("101", "01").Replace("2013", "2014");
                yeniYemek.Ogun     = "Öğle - Akşam";
                yeniYemek.Yemekler = new List <YemekList.Yemek>();
                string[] split = yemek.YemekLunch.Replace("\n", "").Replace("<br>", "").Split('\r');
                for (int i = 0; i < split.Length; i++)
                {
                    if (split[i] != "")
                    {
                        string[] kaloriSplit = split[i].Split('(');
                        string   kalori      = kaloriSplit[kaloriSplit.Length - 1];
                        yeniYemek.Yemekler.Add(new YemekList.Yemek()
                        {
                            Adi = Function.TidyText(split[i].Replace("(" + kalori, "")), Kalori = kalori.ToLower().Replace("kcal)", "").Trim()
                        });
                    }
                }
                yemekList.Add(yeniYemek);
            }

            return(yemekList.OrderBy(x => Convert.ToDateTime(x.Tarih)).ToList());
            //return YemekList.GetList();
        }
Example #2
0
 public Connection GetFoodLists()
 {
     try
     {
         EruWebServisClient client    = new EruWebServisClient();
         ResponseObject     response  = client.YemekList();
         List <YemekModel>  list      = ((YemekModel[])response.DataObject).ToList();
         List <FoodList>    FoodLists = new List <FoodList>();
         foreach (var food in list)
         {
             FoodList foodList = new FoodList();
             foodList.Date  = Convert.ToDateTime(food.date.Split(' ')[0].Replace("101", "01").Replace("2013", "2014"));
             foodList.Foods = new List <Food>();
             string[] split = food.YemekLunch.Replace("\n", "").Replace("<br>", "").Split('\r');
             for (int i = 0; i < split.Length; i++)
             {
                 if (split[i] != "")
                 {
                     string[] kaloriSplit = split[i].Split('(');
                     string   kalori      = kaloriSplit[kaloriSplit.Length - 1];
                     foodList.Foods.Add(new Food()
                     {
                         Name = Function.TidyText(split[i].Replace("(" + kalori, "")), Calorie = kalori.ToLower().Replace("kcal)", "").Trim()
                     });
                 }
             }
             FoodLists.Add(foodList);
         }
         this.State      = true;
         this.Message    = null;
         this.DataObject = new ListModel()
         {
             List = FoodLists.OrderBy(x => x.Date).ToArray()
         };
     }
     catch (Exception)
     {
         this.State      = false;
         this.Message    = "Yemek listesine erişilemiyor..";
         this.DataObject = null;
     }
     return(this);
 }