Exemple #1
0
    static void Main(string[] args)
    {
        using (var db = new SQLContext()) {
          // Create and save a new Blog
          Console.Write("Enter a name for a new Blog: ");
          var name = Console.ReadLine();

          var toDoList = new ToDoList { Title = name };
          db.ToDoLists.Add(toDoList);
          db.SaveChanges();

          // Display all Blogs from the database
          var query = from b in db.ToDoLists
                  orderby b.Title
                  select b;

          Console.WriteLine("All blogs in the database:");
          foreach (var item in query) {
        Console.WriteLine(item.Title);
          }

          Console.WriteLine("Press any key to exit...");
          Console.ReadKey();
        }
    }
Exemple #2
0
        private async Task AddToDoAsync()
        {
            ToDoList toDoList = new ToDoList {
                DateCreated = DateTime.Now.Date
            };

            todos.Add(toDoList);
            await JSRuntime.InvokeVoidAsync("setFocus", $"{toDoList.Id}TitleInputBig");
        }
Exemple #3
0
 public static void ListToDo()
 {
     var aToDoList = new ToDoList(new List <ITODO>()
     {
         new ToDo1(),
         new ToDo2(),
         new ToDo3()
     });
 }
Exemple #4
0
        public void should_mark_done_item()
        {
            var toDoList = new ToDoList();
            var toDoItem = new ToDoItem("name1", DateTime.Now, false);

            toDoList.addItem(toDoItem);
            toDoList.markDoneItem(toDoItem);
            ///Assert.True(toDoList.items[))
        }
 private void DisplayListData(ToDoList list)
 {
     _writer.WriteLine($"Id : {list.Id}");
     _writer.WriteLine($"Title : {list.Title}");
     _writer.WriteLine($"IdOfCreator : {list.IdOfCreator} ");
     _writer.WriteLine($"DateCreated : {list.DateCreated}");
     _writer.WriteLine($"LastModifiedBy : {list.LastModifiedBy}");
     _writer.WriteLine($"LastModifiedAt : {list.LastModifiedAt}");
 }
        private void XLabel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Label    selectedLabel = (Label)sender;
            ToDoList deletedList   = (ToDoList)selectedLabel.Tag;

            process.RemoveToDoList(deletedList);
            MessageBox.Show("The list deleted successfully!");
            RefreshLists();
        }
Exemple #7
0
        /// <summary>
        /// Remove task from list of tasks.
        /// </summary>
        private void RemoveTask(ToDo todo)
        {
            if (todo == null)
            {
                return;
            }

            ToDoList.Remove(todo);
        }
Exemple #8
0
        public void CreateToDoListForUser(string userName, string toDoListName)
        {
            ToDoList        toDoList = new ToDoList();
            ApplicationUser usr      = _context.Users.FirstOrDefault(x => x.UserName == userName);

            toDoList.refUserId    = usr.Id;
            toDoList.ToDoListName = toDoListName;
            _context.ToDoLists.Add(toDoList);
        }
Exemple #9
0
        public IActionResult Update([FromBody] ToDoList todoList)
        {
            var todo = _todoListService.Get(todoList.Id);

            todo.Status = !todo.Status;
            _todoListService.Update(todoList.Id, todo);

            return(Json(todo));
        }
        public void Delete(int toDoListID)
        {
            ToDoList itemToRemove = Get(toDoListID);

            Models
            .ToDoLists
            .Lists[itemToRemove.UserID]
            .Remove(itemToRemove);
        }
Exemple #11
0
        private void setNewTask()
        {
            var toDo = new ToDo();

            toDo.PropertyChanged += onToDoListIsDoneChange;
            toDo.TxtTask          = TxtNewTask;
            ToDoList.Add(toDo);
            ToDoList = new List <ToDo>(ToDoList);
        }
Exemple #12
0
        private async Task HandleSelectedListChangedAsync(ToDoList list)
        {
            SelectedList = list;

            await ItemsViewModel.ShowItemsAsync(list)
            .ConfigureAwait(true);

            OnStateChanged();
        }
        public async Task <ActionResult <ToDoList> > CreateToDoListAsync()
        {
            var list = new ToDoList {
                Id = Guid.NewGuid()
            };
            await _daprClient.SaveStateAsync(StoreName, list.Id.ToString(), list);

            return(list);
        }
Exemple #14
0
        public ActionResult Add(ToDoListView toDoListView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                IToDoListsRepository toDoListsRepository = new ToDoListsRepository(db);
                ToDoList             toDoList            = new ToDoList();

                toDoListView.ConvertTo(toDoListView, toDoList);

                toDoList.UserFK       = SecurityHelper.GetUserPKFromCookie();
                toDoList.CreationDate = DateTime.Now;

                toDoListsRepository.Add(toDoList);
                toDoListsRepository.SaveChanges();

                string[] legalEntitiesSelectedValues = new string[500];
                if (form["LegalEntityPK"] != null)
                {
                    legalEntitiesSelectedValues = ((string)form["LegalEntityPK"]).Split(',');
                }
                else
                {
                    legalEntitiesSelectedValues = null;
                }

                IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);

                if (legalEntitiesSelectedValues != null)
                {
                    // Add work dones
                    foreach (string legalEntity in legalEntitiesSelectedValues)
                    {
                        WorkDone workDone = new WorkDone();

                        workDone.ToDoListFK      = toDoList.ToDoListPK;
                        workDone.LegalEntityFK   = Convert.ToInt32(legalEntity);
                        workDone.CreatedWithToDo = true;

                        workDonesRepository.Add(workDone);
                    }

                    workDonesRepository.SaveChanges();
                }

                TempData["message"] = LayoutHelper.GetMessage("INSERT", toDoList.ToDoListPK);

                return(RedirectToAction("Index", "ToDoList"));
            }
            else
            {
                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                toDoListView.Companies = new MultiSelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("name ASC"), "LegalEntityPK", "Name");

                return(View(toDoListView));
            }
        }
Exemple #15
0
 public ActionResult Create(ToDoList ToDoList)
 {
     if (ModelState.IsValid)
     {
         db.ToDoLists.Add(ToDoList);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ToDoList));
 }
Exemple #16
0
        public async Task <IActionResult> Create([Bind("ID,Name,IsDone")] ToDoList toDoList)
        {
            if (ModelState.IsValid)
            {
                await APIListPost(toDoList);

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
Exemple #17
0
        /// <summary>
        /// Action that makes a PUT request to the API to update the current
        /// ToDoList or create a new one
        /// </summary>
        /// <param name="id">Id of the ToDoList object</param>
        /// <param name="list">ToDoList object</param>
        /// <returns>Status code</returns>
        public async Task <HttpStatusCode> APIListPut(long id, ToDoList list)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://eisj-todoapi.azurewebsites.net");
                var response = await client.PutAsJsonAsync($"/api/todolist/{id}", list);

                return(response.StatusCode);
            }
        }
Exemple #18
0
        private async Task <bool> TaskExists(int id)
        {
            ToDoList task = await _context.GetTaskByIDAsync(id);

            if (task != null)
            {
                return(true);
            }
            return(false);
        }
        public void Add(ToDoList toDoList)
        {
            ToDoListDBContext db = DBContext;
            var Itemslst         = GetList();
            int maxId            = Itemslst != null && Itemslst.Count > 0 ? Itemslst.Max(x => x.Id) : 0;

            toDoList.Id = maxId + 1;
            db.ToDoList.Add(toDoList);
            db.SaveChanges();
        }
        public void When_adding_an_item_to_a_list_that_exists()
        {
            ToDoList toDoList = new ToDoList();
            toDoListRepository.Setup(x => x.FindListByUserName(It.IsAny<string>(), It.IsAny<string>())).Returns(toDoList);

            toDoApplication.AddItemToList(USER_NAME, LIST_NAME, ITEM_NAME);

            Assert.IsTrue(toDoList.Items.Contains(ITEM_NAME));
            toDoListRepository.Verify(x=>x.Save(toDoList));
        }
        public IActionResult Checkedlist(int id, ToDoList toDoList)
        {
            var put = _todolistService.Checkedlist(id, toDoList);

            if (put > 0)
            {
                return(Ok(put));
            }
            return(BadRequest("Checked Failed!"));
        }
Exemple #22
0
        public void CreateToDoList()
        {
            string   name        = "Test todolist add";
            string   description = "Test todolist description";
            ToDoList list        = RunTest(ToDoList.Create(Api, Settings.TestProject, Settings.TestToDoSet, name, description));

            Assert.AreEqual(name, list.name);
            Assert.AreEqual(description, list.description);
            list.SetStatus(Api, Status.trashed).Wait();
        }
 public ActionResult Edit([Bind(Include = "Id,Name,DueDate,IsReOccuring")] ToDoList toDoList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(toDoList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));//After an item Edited return to index Action -List
     }
     return(View(toDoList));
 }
Exemple #24
0
        public async Task <IActionResult> Create([Bind("ID,Task,Priority,Completed,DueDate")] ToDoList item)
        {
            if (ModelState.IsValid)
            {
                await _context.CreateATaskAsync(item);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(item));
        }
 public ActionResult EditList([Bind(Include = "Id,Desc")] ToDoList toDoList)
 {
     if (ModelState.IsValid)
     {
         db.ToDoLists.First(m => m.Id == toDoList.Id).Desc = toDoList.Desc;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
Exemple #26
0
 public bool ToDoListUpdate(int id, ToDoList toDoList)
 {
     if (ToDoListRemove(id))
     {
         ToDoListAdd(toDoList);
         _cache.Set(Config.CacheKey.ToDoListGetAll, () => ToDoLists);
         return(true);
     }
     return(false);
 }
Exemple #27
0
        public async Task <int> Handle(AddToDoListCommand request, CancellationToken cancellationToken)
        {
            int userId = _userAccessor.GetUserId();

            request.ToDoList.UserId = userId;
            var      db   = _instanceDB.Get <IToDoListDbManager>();
            ToDoList list = _dTO.MapListDTOToAddEntity(request.ToDoList);

            return(await db.AddToDoList(list));
        }
 public ActionResult Edit([Bind(Include = "ToDoListID,Title")] ToDoList toDoList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(toDoList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(toDoList));
 }
Exemple #29
0
        public bool Initialize_ToDoList()
        {
            if (ToDoList != null)
            {
                ToDoList.CreateTestItems();
                return(true);
            }

            return(false);
        }
Exemple #30
0
 public void AddToDoList(string title, string color = "#ffffff")
 {
     if (userService.CurrentUser != null)
     {
         var list = new ToDoList(title, color);
         list.UserId = userService.CurrentUser.Id;
         unitOfWork.ToDoListRepository.Create(list);
         unitOfWork.Save();
     }
 }
Exemple #31
0
        public void TestgetStatus()
        {
            ToDoList todoList = new ToDoList();

            Tasks getstatus = new Tasks("test");

            todoList.addTask(getstatus);
            Assert.IsTrue(todoList.getStatus("test") == true);
            Assert.Fail("Not implemented yet");
        }
Exemple #32
0
 public List <ToDoList> UpdateToDoList(int id, ToDoList toDoList)
 {
     if (this.Remove(id))
     {
         this.AddNewToDoList(toDoList);
         db.SaveChanges();
         return(db.Books.ToList());
     }
     return(db.Books.ToList());
 }
 public async Task<HttpResponseMessage> Put(Guid id, ToDoList toDoList) {
     await Session.StoreAsync(toDoList);
     return Request.CreateResponse(HttpStatusCode.Created, toDoList);
 }
Exemple #34
0
 public static void ShowWindow()
 {
     if (_toDoList != null) return;
     _toDoList = (ToDoList)EditorWindow.GetWindow(typeof(ToDoList));
 }
Exemple #35
0
 public Home()
 {
     InitializeComponent();
     TodoList = new ToDoList();
     DisableButtons();
 }