private List<Recette> MapRECIPE(IDataReader reader)
        {
            List<Recette> result = new List<Recette>();

            while (reader.Read())
            {
                Recette recette = new Recette();
                recette.Ingrédients = new List<string>();
                recette.Instructions = new List<string>();

                recette.ID = Tools.ChangeType<int>(reader["id"]);
                recette.Nom = Tools.ChangeType<string>(reader["nom"]);
                recette.Description = Tools.ChangeType<string>(reader["description"]);

                string ing = Tools.ChangeType<string>(reader["ingredients"]);
                string inst = Tools.ChangeType<string>(reader["instructions"]);

                ing = ing.Replace('\t', ' ').Replace('\r', ' ').Replace('\n', ' ');
                List<string> ingredients = ing.Split('|').ToList();
                foreach (string ingredient in ingredients)
                {
                    string[] splitted = ingredient.Split(';');
                    recette.Ingrédients.Add(string.Format(splitted[0].Trim(), splitted[1], splitted[2]));
                }

                inst = inst.Replace('\t', ' ').Replace('\r', ' ').Replace('\n', ' ');
                List<string> instructions = inst.Split('.').ToList();
                foreach (string instruction in instructions)
                    recette.Instructions.Add(instruction.Trim());

                result.Add(recette);
            }

            return result;
        }
        public void Update(DataContracts.Recette entity)
        {
            Recette rec = _source.Find(o => o.ID == entity.ID);

            if (rec != null)
            {
                rec.Ingrédients  = entity.Ingrédients;
                rec.Instructions = entity.Instructions;
                rec.Nom          = entity.Nom;
                rec.Description  = entity.Description;
            }
        }
Example #3
0
 public void Update(Recette entity)
 {
     throw new NotImplementedException();
 }
Example #4
0
 public void Insert(Recette entity)
 {
     throw new NotImplementedException();
 }
 public void Delete(DataContracts.Recette entity)
 {
     _source.RemoveAll(o => o.ID == entity.ID);
 }
 public void Insert(DataContracts.Recette entity)
 {
     _source.Add(entity);
 }
 public void Delete(DataContracts.Recette entity)
 {
     throw new NotImplementedException();
 }