Ejemplo n.º 1
0
        private bool TryGetTodoItem(out todoitem todo)
        {
            int id;

            if (TryReadId(out id))
            {
                todo = db.todoitem.SingleOrDefault(x => x.Id == id);

                if (todo != null)
                {
                    return(true);
                }
                else
                {
                    Console.WriteLine("Todo item not found. Please enter valid todo item id.");
                    return(false);
                }
            }
            else
            {
                Console.WriteLine("Todo item not found. Please enter valid todo item id.");
                todo = null;
                return(false);
            }
        }
Ejemplo n.º 2
0
        internal void Add()
        {
            Console.Write("Description>");
            var description = Console.ReadLine().Trim();

            var addMe = new todoitem();

            addMe.Description = description;
            addMe.TimeCreated = DateTime.Now;

            this.db.todoitem.Add(addMe);
            this.db.SaveChanges();

            Console.WriteLine("Todo item has been added.");
        }
Ejemplo n.º 3
0
        // Code review: var keyword can be used only in function body variable declaration. For other uses variable type has to be explicit. Try to avoid using tmp for variable name. It's not any good. Consider using "getMe" variable name.
        private bool TryGetTodoItem(todoitem tmp)
        {
            int id;

            if (TryReadId(out id))
            {
                tmp = db.todoitem.SingleOrDefault(x => x.Id == id);

                if (tmp != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }