public void Can_Add_Update_and_Delete_Todo_item()
        {
            using (var redisManager = new PooledRedisClientManager())
            using (var redis = redisManager.GetClient())
            {
                var redisTodos = redis.As<Todo>();
                var todo = new Todo
                {
                    Id = redisTodos.GetNextSequence(),
                    Content = "Learn Redis",
                    Order = 1,
                };

                redisTodos.Store(todo);

                Todo savedTodo = redisTodos.GetById(todo.Id);
                savedTodo.Done = true;
                redisTodos.Store(savedTodo);

                "Updated Todo:".Print();
                redisTodos.GetAll().ToList().PrintDump();

                redisTodos.DeleteById(savedTodo.Id);

                "No more Todos:".Print();
                redisTodos.GetAll().ToList().PrintDump();
            }
        }
 public TodoViewModel(Todo t)
 {
     this.id = t.Id;
     this.text = t.Text;
     this.done = t.Done;
     this.order = t.Order;
 }
        /**
         * <summary>
         * This event handler updates todo with the new completed state
         * </summary>
         *
         * @param {object} sender
         * @param {EventArgs} e
         * @returns {void}
         */
        protected void chkCompleted_CheckedChanged(object sender, EventArgs e)
        {
            // Get the clicked checkbox
            CheckBox chk = (CheckBox)sender;

            // Get the row
            GridViewRow gvr = (GridViewRow)chk.NamingContainer;
            var selectedRow = gvr.RowIndex;

            // get the selected StudentID using the Grid's DataKey collection
            int TodoID = Convert.ToInt32(TodoGridView.DataKeys[selectedRow].Values["TodoID"]);

            // Create a new Todo item
            Todo newTodo = new Todo();

            using (TodoConnection db = new TodoConnection())
            {
                // get the current student from EF DB
                newTodo = (from todo in db.Todos
                           where todo.TodoID == TodoID
                           select todo).FirstOrDefault();

                newTodo.Completed = chk.Checked;

                try
                {
                    db.SaveChanges();
                    Response.Redirect("/Todos/TodoList.aspx");
                }
                catch (Exception ex)
                {
                    // ...
                }
            }
        }
 public void Todoリストに最初に追加したTodoが削除すると2番目に追加した要素が最初に追加したものになること()
 {
     var secondTodo = new Todo("second title", "second detail");
     todoList.Add(secondTodo);
     todoList.RemoveFirstTodo();
     Assert.That(todoList.GetFirstTodo(), Is.EqualTo(secondTodo));
 }
 // POST: api/TodoList
 public void Post(Todo todo)
 {
     string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
     todo.Owner = owner;
     db.Todoes.Add(todo);
     db.SaveChanges();
 }
        static void Main(string[] args)
        {
            ToDosDB todoEntities = new ToDosDB();

            for (int i = 0; i < 10; i++)
            {
                var cat = new Category()
                {
                    Name = "new category" + i,

                };
                todoEntities.Categories.Add(cat);

                for (int m = 0; m < 20; m++)
                {
                    var todo = new Todo()
                    {
                        Title = "new todo" + i + m,
                        Body = "bodyOfTodo" + i + m,
                        Category = cat,
                        LastChangeDate = DateTime.Now,
                    };
                    todoEntities.Todos.Add(todo);
                }
            }
            todoEntities.SaveChanges();
        }
Exemple #7
0
        public JsonResult Post()
        {
            var key = Request.Cookies["todolistapp"]["todos"];
            var todolist = _db.TodoLists.Single(tl => tl.Key == key);

            var todo = new Todo();

            var todoJson = new StreamReader(Request.InputStream).ReadToEnd();

            JavaScriptSerializer js = new JavaScriptSerializer();
            todo = js.Deserialize<Todo>(todoJson);

            todolist.Todos.Add(todo);
            if (ModelState.IsValid)
            {
                _db.Entry(todolist).State = EntityState.Modified;
                _db.SaveChanges();
            }

            return Json(new
            {
                id = todo.Id,
                content = todo.Content,
                order = todo.Order,
                done = todo.Done
            }, JsonRequestBehavior.AllowGet);
        }
        public void Crud_TODO_App()
        {
            //Thread-safe client factory
            var redisManager = new PooledRedisClientManager(TestConfig.SingleHostConnectionString);

            redisManager.ExecAs<Todo>(redisTodos =>
            {
                var todo = new Todo
                {
                    Id = redisTodos.GetNextSequence(),
                    Content = "Learn Redis",
                    Order = 1,
                };

                redisTodos.Store(todo);

                Todo savedTodo = redisTodos.GetById(todo.Id);
                savedTodo.Done = true;

                redisTodos.Store(savedTodo);

                redisTodos.DeleteById(savedTodo.Id);

                var allTodos = redisTodos.GetAll();

                Assert.That(allTodos.Count, Is.EqualTo(0));
            });
        }
Exemple #9
0
        public Todo Obtener_ARJ()
        {
            BinaryReader rdr = new BinaryReader(File.OpenRead(archivo));
            Todo final = new Todo();

            final.imgs = rdr.ReadUInt16();
            Image[] imagenes = new Image[final.imgs];
            final.tipo = rdr.ReadUInt16() == 3 ? ColorDepth.Depth4Bit : ColorDepth.Depth8Bit;
            uint paleta_size = rdr.ReadUInt32();

            for (int i = 0; i < imagenes.Length; i++)
            {
                imagenes[i] = Obtener_ImagenARJ(rdr.BaseStream.Position, final.tipo);
                rdr.BaseStream.Position = (long)imagenes[i].segmentos[imagenes[i].imgs - 1].offSet +
                    imagenes[i].segmentos[imagenes[i].imgs - 1].length + 12;
            }

            Paleta paleta = Obtener_PaletaARJ(rdr.BaseStream.Position, paleta_size);

            // Obtenemos los nombres de las imágenes.
            rdr.BaseStream.Position = (long)paleta.offset + paleta.length + 0x1E;
            uint numNombres = rdr.ReadUInt32() - 1;
            rdr.BaseStream.Seek(0x13 + 0xB, SeekOrigin.Current);
            for (uint i = 0; i < numNombres & i < imagenes.Length; i++)
            {
                imagenes[i].name = new String(rdr.ReadChars(0x13));
                imagenes[i].name = imagenes[i].name.Substring(0, imagenes[i].name.IndexOf('\0'));

                rdr.BaseStream.Seek(0xB, SeekOrigin.Current);
            }

            rdr.Close();

            for (int i = 0; i < imagenes.Length; i++)
            {
                try { imagenes[i].bitmap = Transformar_ImagenARJ(imagenes[i], paleta); }
                catch // En caso de error puede deberse a que la imagen tenga mal las posiciones x e y, intentamos arreglarlo
                {
                    Console.WriteLine("Error al intentar crear la animación. Intentando arreglarla.");
                    for (int j = 0; j < imagenes[i].imgs; j++)
                        if (j > 0)
                            if (imagenes[i].segmentos[j].posX > imagenes[i].segmentos[j - 1].posX)
                                imagenes[i].segmentos[j].posY = imagenes[i].segmentos[j - 1].posY;

                    imagenes[i].bitmap = Transformar_ImagenARJ(imagenes[i], paleta);
                }
                if (imagenes[i].height < imagenes[i].bitmap.Height || imagenes[i].width < imagenes[i].bitmap.Height)
                    imagenes[i].bitmap = imagenes[i].bitmap.Clone(new Rectangle(0, 0, imagenes[i].width, imagenes[i].height),
                        System.Drawing.Imaging.PixelFormat.DontCare);

                if (imagenes[i].name == "" | imagenes[i].name == null)
                    imagenes[i].name = "Sin Nombre " + i.ToString();
            }

            final.imagenes = imagenes;
            final.paleta = paleta;

            return final;
        }
 public HttpResponseMessage Todos(long Id, TodoInput todoInput)
 {
     var todo = new Todo() { Title = todoInput.Title, Completed = false };
     var list = _repo.Get(Id);
     list.AddTodo(todo);
     _repo.Store(list);
     return Request.CreateResponse(HttpStatusCode.OK, new TodoDisplay { Title = todoInput.Title, Id = todo.Id, Completed = false });
 }
Exemple #11
0
 public JsonResult Create(Todo todo)
 {
     if (ModelState.IsValid)
     {
         todo.Create();
     }
     return Json(todo);
 }
 public ActionResult Post(TodoViewModel newTodo)
 {
     Todo todo = new Todo();
     UpdateModel(todo, new[] { "Text", "Done", "Order" });
     ValidateModel(todo);
     repository.Save();
     return Json(new TodoViewModel(todo));
 }
Exemple #13
0
 public Guid Add(Todo todo)
 {
     lock (todoUpdateLockObj)
     {
         App.DocumentSession.Store(todo);
         return (todo.Id);
     }
 }
Exemple #14
0
 public JsonResult Edit(Todo todo)
 {
     if (ModelState.IsValid)
     {
         todo.Update();
     }
     return Json(todo);
 }
Exemple #15
0
        public void can_create_a_todo()
        {
            var todo = new Todo { Body = "Get some new boots", Done = false };
            var request = new Todos { Todo = todo };

            SendToEachEndpoint<TodosResponse>(request, HttpMethods.Post, response => {
                Assert.That(response.Todos[0], Is.Not.Null);
            });
        }
Exemple #16
0
    private Todo CreateTodo()
    {
        var todo = new Todo {Title = "Build Repositories",
          Outcome = "Database is working"};
        repository.SaveOrUpdate(todo);

        session.Flush();
        return todo;
    }
Exemple #17
0
 public bool Update(Todo todo)
 {
     lock (todoUpdateLockObj)
     {
         todo.ModifiedDt = DateTime.Now;
         App.DocumentSession.Store(todo);
         //Task.Run(async () => { await App.DocumentSession.FlushAsync(); });
     }
     return true;
 }
Exemple #18
0
        public IHttpActionResult AddNew(Todo todo)
        {
            if (ModelState.IsValid)
            {
                var newTodo = TodoInMemoryRepository.Add(todo);
                return this.Ok(newTodo);
            }

            return this.BadRequest(ModelState);
        }
Exemple #19
0
 public void Delete(Todo todo)
 {
     lock (todoUpdateLockObj)
     {
         if (App.DocumentSession.Load<Todo>(todo.Id)!=null)
         {
             App.DocumentSession.Delete<Todo>(todo);
         }
     }
 }
Exemple #20
0
        public HttpResponseMessage Post(Todo item)
        {
            Uow.Todos.Add(item);
            Uow.Commit();

            var response = Request.CreateResponse(HttpStatusCode.Created, item);
            response.Headers.Location = new Uri(Url.Link(RouteConfig.ControllerAndId, new { id = item.Id}));

            return response;
        }
 // PUT: api/TodoList
 public void Put(Todo todo)
 {
     string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
     Todo xtodo = db.Todoes.First(a => a.Owner == owner && a.ID == todo.ID);
     if (todo != null)
     {
         xtodo.Description = todo.Description;
         db.SaveChanges();
     }
 }
        public void TodoInsert()
        {
            var todo = new Todo { LastChange = DateTime.Now, CategoryId = 1 };

            this.TryUpdateModel(todo);

            if (this.ModelState.IsValid)
            {
                this.TodoService.Add(todo.Title, todo.Text, todo.CategoryId);
            }
        }
Exemple #23
0
 static public void DoTests()
 {
     Todo t = new Todo();
     t.InitAll();
     t.TODO1();
     t.TODO2();
     t.TODO3();
     t.TODO4();
     t.TODO5();
     t.TODO6();            
 }
Exemple #24
0
 public Todo Store(Todo todo)
 {
     Todo existing = todos.FirstOrDefault(x => x.Id == todo.Id);
     if (existing == null)
     {
         long newId = todos.Count > 0 ? todos.Max(x => x.Id) + 1 : 1;
         todo.Id = newId;
     }
     todos.Add(todo);
     return todo;
 }
Exemple #25
0
    public void Title_Length_Should_Be_To_Maximum_Of_25_Characters()
    {
        Todo longTodo = new Todo {Title="123456789ABCDEF123456789ABCDEF"};
          Todo twentyFiveCharacterTodo =
        new Todo{Title="123456789ABCDEF1234567"};
          Todo shortTodo = new Todo{Title="1234"};

          Assert.IsFalse(IsValid(longTodo));
          Assert.IsTrue(IsValid(twentyFiveCharacterTodo));
          Assert.IsTrue(IsValid(shortTodo));
    }
Exemple #26
0
        public ActionResult Create(Todo todo)
        {
            try
            {
                Todo.ThingsToBeDone.Add(todo);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemple #27
0
        public ActionResult Edit(string oldTitle, Todo item)
        {
            try
            {
                Todo.ThingsToBeDone.RemoveAll(aTodo => aTodo.Title == oldTitle);
                Todo.ThingsToBeDone.Add(item);

                return RedirectToAction("Index");
            }
            catch (Exception)
            {
                return View();
            }
        }
            public void 追加されたTodoが全部見れること()
            {
                // TDDBCに参加するというストーリ
                var todo1 = new Todo("参加登録", "TDDBCに参加を表明する");
                var todo2 = new Todo("環境準備", "TDDができるような環境を用意する");

                service.Add(todo1);
                service.Add(todo2);
                // Todoリストを確認する
                var actual = service.WatchAllTodo();
                Assert.That(actual, Has.Member(todo1));
                Assert.That(actual, Has.Member(todo2));
                // ユーザへの表示はWatchAllTodoの返却値を表示オブジェクトに丸投げする
            }
Exemple #29
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            using (var reader= new StreamReader(controllerContext.RequestContext.HttpContext.Request.InputStream))
            {
                var rawXml = XmlReader.Create(reader);
                XDocument doc = XDocument.Load(rawXml);
                var todoTitle = doc.Root.Element(XName.Get("title")).Value;

                var todo = new Todo();
                todo.Title = todoTitle;
                //bindingContext.Model = todo;
                //? why both set to context and return?
                return todo;
            }
        }
 public Todo Store(Todo todo)
 {
     var existing = todos.FirstOrDefault(x => x.Id == todo.Id);
     if (existing == null)
     {
         var newId = todos.Count > 0 ? todos.Max(x => x.Id) + 1 : 1;
         todo.Id = newId;
         todos.Add(todo);
     }
     else
     {
         existing.PopulateWith(todo);
     }
     return todo;
 }
Exemple #31
0
 public async Task UpdateAsync(Todo todo)
 {
     await _http.PutAsJsonAsync <Todo>($"api/Todos/{todo.Id}", todo);
 }
Exemple #32
0
 public bool ValidateTodo(Todo todo)
 {
     //some validation
     throw new ValidationException("Invalid todo");
 }
 public IActionResult UpdateTodo(int id, [FromBody] Todo todo)
 {
     _service.UpdateTodo(id, todo);
     return(Ok(todo));
 }
Exemple #34
0
 public void UpdateTodo(Todo t)
 {
 }
Exemple #35
0
 public string Add(Todo todo)
 {
     _todoRepository.Add(todo);
     return(todo.Id.ToString());
 }
Exemple #36
0
 public bool Update(Todo todo)
 {
     return(_todoRepository.Update(todo));
 }
Exemple #37
0
 public async Task AddAsync(Todo todo)
 {
     await _http.PostAsJsonAsync <Todo>("api/Todos", todo);
 }
 public async Task SetCompletedAsync(Todo todo)
 {
     _logger.Log($"Set todo ({todo.Id}) '{todo.Text}' to completed.");
     await _todoRepository.DeleteAsync(todo);
 }
 public async Task Update(Todo todo)
 {
     _context.Entry(todo).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Exemple #40
0
 public Todo UpdateTodo(Todo todo)
 {
     todos[todos.FindIndex(x => x.Id == todo.Id)] = todo;
     return(todo);
 }
Exemple #41
0
 public void TestInitialize()
 {
     todoRepository = new TodoRepository();
     todo           = new Todo(false, "Some todo message");
     todoRepository.Create(todo);
 }
Exemple #42
0
 public void DeleteTodo(Todo todo)
 {
     todos.Remove(todos.Find(x => x.Id == todo.Id));
 }
 public Todo Post([FromBody] Todo value)
 {
     _db.Todos.Add(value);
     _db.SaveChanges();
     return(value);
 }
 public async Task AddAsync(Todo todo)
 {
     await _todoRepository.AddAsync(todo);
 }
Exemple #45
0
 public async Task DeleteAsync(Todo todo)
 {
     await _http.DeleteAsync($"api/Todos/{todo.Id}");
 }
Exemple #46
0
        void flowLayoutPanel_DragDrop(object sender, DragEventArgs e)
        {
            TaskItem          data               = (TaskItem)e.Data.GetData(typeof(TaskItem));
            Panel             _destination       = (Panel)sender;
            VScrollProperties lastScrollPosition = _destination.VerticalScroll;
            Control           _source            = (Panel)data.Parent;

            SortedDictionary <int, Control> list = new SortedDictionary <int, Control>();
            int currentIndex = -1;

            foreach (Control control in _destination.Controls)
            {
                int i = _destination.Controls.GetChildIndex(control, false);
                if (control != data)
                {
                    list.Add(i * 10, control);
                }
                else
                {
                    currentIndex = i * 10;
                }
            }

            if (_source != _destination)
            {
                // Add control to panel
                _destination.Controls.Add(data);
                data.Width = _destination.Width - 14;

                // Reorder
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);

                list.Add(((index * 10)) - 5, data);

                _destination.Invalidate();
                _source.Invalidate();
            }
            else
            {
                Point p     = _destination.PointToClient(new Point(e.X, e.Y));
                var   item  = _destination.GetChildAtPoint(p);
                int   index = _destination.Controls.GetChildIndex(item, false);
                if (index * 10 < currentIndex)
                {
                    list.Add(((index * 10)) - 5, data);
                }
                else
                {
                    list.Add(((index * 10)) + 5, data);
                }

                _destination.Invalidate();
            }

            int newIndex = list.Count;

            _destination.Controls.Clear();
            foreach (KeyValuePair <int, Control> co in list)
            {
                _destination.Controls.Add(co.Value);
                ((KanbanPosition)co.Value.Tag).Position = newIndex;
                newIndex--;
            }

            foreach (Control control in _destination.Controls)
            {
                int i = _destination.Controls.GetChildIndex(control, false);
                ((KanbanPosition)control.Tag).Position = i;
            }

            if (data.Tag != null && data.Tag.GetType() == typeof(KanbanPosition))
            {
                //((KanbanPosition)data.Tag).Position = _destination.Controls.GetChildIndex(data, false);
                ((KanbanPosition)data.Tag).Status = (Status)_destination.Tag;


                SortableBindingList <Todo> todos = (SortableBindingList <Todo>)todoBindingSource.DataSource;
                var task = from todo in todos
                           where todo.pId == ((KanbanPosition)data.Tag).TaskPid
                           select todo;



                if (task.Count() > 0)
                {
                    Todo todo = (Todo)task.First();
                    todo.Status = (Status)_destination.Tag;
                    //dataGridViewKanbanTasks.DataSource = new object();
                    //dataGridViewKanbanTasks.DataSource = todoBindingSource;
                }
            }
            HasChanges = true;
            _destination.ScrollControlIntoView(data);
        }
Exemple #47
0
        public async Task <Todo> TodoDetailsAsync(long id)
        {
            Todo todo = await todoContext.Todos.FirstOrDefaultAsync(t => t.Id == id);

            return(todo);
        }
Exemple #48
0
        public bool Update(Todo todo)
        {
            var affectedRows = connection.Execute("exec todo_sp_update @Id, @Text, @IsCompleted", todo);

            return(affectedRows > 0);
        }
Exemple #49
0
        public async Task AddTodoAsync(Todo newTodo)
        {
            await todoContext.Todos.AddAsync(newTodo);

            await todoContext.SaveChangesAsync();
        }
Exemple #50
0
        public async Task Test_Create_Todo()
        {
            Todo todo1 = new Todo()
            {
                Title       = "Todo 1",
                Description = "Todo 1 Description",
                Expiry      = DateTime.Now,
                Completion  = 30
            };
            Todo todo2 = new Todo()
            {
                Title       = "Todo 2",
                Description = "Todo 2 Description",
                Expiry      = DateTime.Now,
                Completion  = 30
            };

            Todo todo3 = new Todo()
            {
                Title       = "Todo 3",
                Description = "Todo 3 Description",
                Expiry      = DateTime.Now,
                Completion  = 30
            };

            Todo todo4 = new Todo()
            {
                Title       = "Todo 4",
                Description = "Todo 4 Description",
                Expiry      = DateTime.Now,
                Completion  = 30
            };
            Todo todo5 = new Todo()
            {
                Title       = "Test",
                Description = "Todo 5 Description",
                Expiry      = DateTime.Now,
                Completion  = 30
            };

            List <Todo> todoList = new List <Todo>();

            todoList.Add(todo1);
            todoList.Add(todo2);
            todoList.Add(todo3);
            todoList.Add(todo4);
            todoList.Add(todo5);
            var response = new HttpResponseMessage();

            foreach (Todo todo in todoList)
            {
                var stringContent = JsonConvert.SerializeObject(todo, Formatting.Indented);
                response = await _client.PostAsync("/todoes"
                                                   , new StringContent(stringContent
                                                                       ,
                                                                       Encoding.UTF8,
                                                                       "application/json"));

                response.EnsureSuccessStatusCode();
            }


            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
        }
Exemple #51
0
        public async Task <Todo> GetTodosById(int id)
        {
            Todo path = await _context.Todos.FindAsync(id);

            return(path);
        }
 public IActionResult Edit(Todo todo)
 {
     TodoRepository.UpdateTodo(todo);
     return(RedirectToAction("List"));
 }
Exemple #53
0
 private void Todo_Click(object sender, EventArgs e)
 {
     Todo.PerformClick();
 }
Exemple #54
0
        public async Task <ActionResult> Create([Bind("Title,Owner")] Todo todo)
        {
            await _downstreamWebApi.PostForUserAsync <Todo, Todo>(ServiceName, "api/todolist", todo);

            return(RedirectToAction("Index"));
        }
Exemple #55
0
 public Todo Create(Todo todo)
 {
     //Usando o Dapper para comunicacao com o banco
     todo.Id = connection.QueryFirst <int>("exec todo_sp_create @Text, @IsCompleted", todo);
     return(todo);
 }
 public void Update(Todo task)
 {
     this.context.Update(task);
     this.context.SaveChanges();
 }
 public ActionResult CreateTodo(Todo todo)
 {
     _context.Todos.Add(todo);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public void Create(Todo task)
 {
     this.context.Add(task);
     this.context.SaveChanges();
 }
Exemple #59
0
 public Task <Todo> Create(Todo todo)
 {
     return(Task.FromResult(todo));
 }
        public IActionResult AddTodo([FromBody] Todo todo)
        {
            var newTodo = _service.AddTodo(todo);

            return(Ok(newTodo));
        }