public async Task<IHttpActionResult> PostToDoItem(ToDoItem toDoItem) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.ToDoItems.Add(toDoItem); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ToDoItemExists(toDoItem.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = toDoItem.Id }, toDoItem); }
private async void UpdateCheckedTodoItem(ToDoItem item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await todoTable.UpdateAsync(item); items.Remove(item); }
private void AddNewItem(string content) { item = new ToDoItem(); item.Title = content; item.CreateTime = DateTime.Now; item.IsCompleted = false; item.Note = ""; item.Priority = 0; item.Remind = false; // 默认提醒关闭 if (_GroupName != null && _GroupName.Equals(TOMORROW)) { item.RemindTime = DateTime.Now.AddDays(1); } else if (_GroupName != null && _GroupName.Equals(LATER)) { item.RemindTime = DateTime.Now.AddDays(2); } else { item.RemindTime = DateTime.Now; } App.ViewModel.AddToDoItem(item, _GroupName); }
public async Task<IHttpActionResult> PutToDoItem(Guid id, ToDoItem toDoItem) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != toDoItem.Id) { return BadRequest(); } db.Entry(toDoItem).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToDoItemExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
private async void InsertTodoItem(ToDoItem todoItem) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await todoTable.InsertAsync(todoItem); items.Add(todoItem); }
private ToDoItem Clone(ToDoItem entity) { var clonedEntity = new ToDoItem { Id = entity.Id, CreationTime = entity.CreationTime, State = entity.State, Description = entity.Description }; return clonedEntity; }
public async Task InsertTodoItemAsync (ToDoItem todoItem) { try { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await todoTable.InsertAsync (todoItem); Items.Add (todoItem); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public void UpdateToDoItem(ToDoProxyItem item) { var client = new ToDoManagerClient(); var toDoItem = new ToDoItem() { Name = item.Name, IsCompleted = item.IsCompleted, ToDoId = item.ToDoId, UserId = item.UserId }; client.UpdateToDoItem(toDoItem); }
public void Put(string id, [FromBody]UpdateTaskViewModel value) { ToDoItem item = new ToDoItem { Id = id, IsCompleted = value.Completed, Name = value.Name, Note = value.Note, Date = value.Date }; service.UpdateTask(value.List, item); }
public void AddTask(string email, string name, DateTime date, string listId) { var list = _uow.Users.GetFirst(u => u.Email == email) .ToDoLists.FirstOrDefault(l => l.Id == listId); var task = new ToDoItem { Name = name, Date = date, List = list }; _uow.ToDoItems.Create(task); _uow.Commit(); }
public async Task CompleteItemAsync (ToDoItem item) { try { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list item.Complete = true; await todoTable.UpdateAsync (item); Items.Remove (item); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine (@"ERROR {0}", e.Message); } }
public ActionResult Create(ToDoItem request) { if (ModelState.IsValid) { string taskName = request.Item; ToDoItem item = new ToDoItem(taskName); db.ToDoItems.Add(item); db.SaveChanges(); return Json(item); } return new HttpStatusCodeResult(HttpStatusCode.BadRequest); }
private async void AddButton_Click(object sender, RoutedEventArgs e) { AddButton.IsEnabled = false; ItemDescriptionTextBox.IsEnabled = false; using (var documentStore = new DocumentStore()) { documentStore.Url = "http://localhost:8080"; documentStore.Initialize(); using (var session = documentStore.OpenAsyncSession()) { var toDoItem = new ToDoItem { Description = ItemDescriptionTextBox.Text }; session.Store(toDoItem); await session.SaveChangesAsync(); AddButton.IsEnabled = true; ItemDescriptionTextBox.IsEnabled = true; ItemDescriptionTextBox.Clear(); Items.Add(toDoItem); } } }
/// <summary> /// adds to-do-list items of type ToDoItem to the listbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addButton_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBoxResult.No; //when there is no name for the item if (inputTextBox.Text == "" || inputTextBox.Text == "Enter To Do Item Here") { result = MessageBox.Show("Please Enter a name for your Item", "No Item Name!", MessageBoxButton.OK); } if (result == MessageBoxResult.OK) { inputTextBox.Text = ""; } // saves only when there is valid name for the item //here the value false is passd b/c it is required by the constructor else { ToDoItem newItem = new ToDoItem(inputTextBox.Text, false); m_ToDoItems.Add(newItem); } }
private void Add(ToDoItem item) { ToDoItemControl c = new ToDoItemControl(); c.Size = new Size(1, 30); c.ToDoItem = item; c.Font = Font; c.Location = new Point(0, Controls.Count * 30); c.Width = (int)((double)ClientSize.Width * 0.9); c.Margin = new Padding(0); c.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; if (people != null) { personToFindID = item.PersonID; c.Person = people.Find(FindPerson); } c.Editing += new EventHandler(c_Editing); ListenToItem(item, true); Controls.Add(c); controlsByItem[item] = c; }
public async Task <ActionResult> Edit(int id, TodoItemViewModel viewModel) { try { var user = await GetCurrentUserAsync(); var item = new ToDoItem() { Id = viewModel.Id, Title = viewModel.Title, ToDoStatusId = viewModel.TodoStatusId, ApplicationUserId = user.Id }; _context.ToDoItem.Update(item); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void PutSuccessful() { //Arrange var controller = new ToDoController(new ToDoBL(new ToDoRepository(), new DataCache())); controller.Request = new HttpRequestMessage { Method = HttpMethod.Put, }; var toDoItems = controller.Get(); var results = toDoItems.Content.ReadAsAsync <System.Collections.Generic.List <Domain.Models.ToDoItem> >().Result; int id = results[results.Count - 1].Id; var controllerPut = new ToDoController(new ToDoBL(new ToDoRepository(), new DataCache())); controllerPut.Request = new HttpRequestMessage { Method = HttpMethod.Delete, }; controllerPut.Configuration = new HttpConfiguration(); ToDoItem request = new ToDoItem() { Id = id, Name = "Test Data for Azure " + id }; //Actual var response = controllerPut.Put(request); //Assert Assert.IsNotNull(response); Assert.IsNotNull(response.Content); Assert.IsTrue(response.IsSuccessStatusCode); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); }
public void PutFailure() { //Arrange var controller = new ToDoController(new ToDoBL(new ToDoRepository(), new DataCache())); controller.Request = new HttpRequestMessage { Method = HttpMethod.Put, }; ToDoItem request = new ToDoItem() { Id = 0, Name = "Test Data for Azure" }; //Actual var response = controller.Put(request); //Assert Assert.IsNotNull(response); Assert.IsNull(response.Content); Assert.IsFalse(response.IsSuccessStatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task <IActionResult> Post([FromBody] ToDoItem toDoItem) { try { _toDoItemBpc.InsertToDoItem(toDoItem); if (await _toDoItemBpc.SaveAllAsync()) { var uri = Url.Link("ToDoItemsByUser", new { userId = toDoItem.UserId }); return(Created(uri, toDoItem)); } else { _logger.LogWarning($"Could not save task in the database. itemId: {toDoItem.ToDoItemId}"); } } catch (Exception e) { _logger.LogError($"Something went wrong when saving the task. itemId: {toDoItem.ToDoItemId} - {e.Message}"); } return(BadRequest()); }
public void AddItemSavesItemAndReturnsValidModel() { var itemToAdd = new ToDoItem { Title = "New Item", DueDate = new DateTime(2020, 12, 30), }; var mockContext = new Mock <IToDoContext>(); mockContext.Setup(context => context.ToDoItems.Add(It.IsAny <EntityModel.ToDoItem>())) .Returns(new EntityModel.ToDoItem()); var repository = new ToDoItemsRepository(mockContext.Object); var result = repository.AddItem(itemToAdd).Result; mockContext.Verify(context => context.ToDoItems.Add(It.IsAny <EntityModel.ToDoItem>()), Times.Once); mockContext.Verify(context => context.SaveChangesAsync(), Times.Once); Assert.AreEqual(itemToAdd.Title, result.Title); Assert.AreEqual(itemToAdd.DueDate, result.DueDate); Assert.IsFalse(result.IsDone); Assert.IsFalse(result.IsOverDue); }
// GET: ToDoItems/Create public ActionResult Create() { var toDoItem = new ToDoItem(); toDoItem.MeetingDate = DateTime.Now; toDoItem.MeetingHour = DateTime.Now; toDoItem.FinishDate = DateTime.Now; toDoItem.FinishHour = DateTime.Now; toDoItem.PlannedDate = DateTime.Now; toDoItem.PlannedHour = DateTime.Now; toDoItem.ReviseDate = DateTime.Now; toDoItem.ScheduledOrganizationDate = DateTime.Now; toDoItem.ReviseHour = DateTime.Now; toDoItem.ScheduledOrganizationHour = DateTime.Now; ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name"); ViewBag.CustomerId = new SelectList(db.Customers, "Id", "Name"); ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "Name"); ViewBag.ManagerId = new SelectList(db.Contacts, "Id", "FirstName"); ViewBag.OrganizatorId = new SelectList(db.Contacts, "Id", "FirstName"); ViewBag.SideId = new SelectList(db.Sides, "Id", "Name"); return(View(toDoItem)); }
public ToDoItem Update(ToDoItem movie, out string message) { if (movie == null) { message = "ToDoItem cannot be null,"; return(null); } var errors = ObjectValidator.Validate(movie); if (errors.Count() > 0) { //return first error message = errors.ElementAt(0).ErrorMessage; return(null); } //verify it exist, and is unique var existing = GetCore(movie.Title); if (existing != null && existing.Id != movie.Id) { message = "Product already exists."; return(null); } existing = existing ?? GetCore(movie.Id); if (existing == null) { message = "Product not found"; return(null); } message = null; return(UpdateCore(movie)); }
public ToDoItem PutUpdatedToDoItem(int id, ToDoItem item) { lock (db) { // Find the existing item var toUpdate = db.SingleOrDefault(i => i.ID == id); if (toUpdate == null) { throw new HttpResponseException( Request.CreateResponse(HttpStatusCode.NotFound) ); } // Update the editable fields and save back to the "database" toUpdate.Title = item.Title; toUpdate.Finished = item.Finished; // Notify the connected clients Hub.Clients.updateItem(toUpdate); // Return the updated item return(toUpdate); } }
public void GetItemWithTextSearch() { //Arrange var filter = new SearchItemFilter { PageNumber = 0, TakeCount = 10, SearchPhrase = "meet", ItemType = Contracts.Enums.ToDoTypeEnum.Meeting, PeriodType = Contracts.Enums.TimePeriodEnum.AllTime }; var item = new ToDoItem { ItemType = Contracts.Enums.ToDoTypeEnum.Meeting, Title = "meet in cafe", StartDate = DateTime.Now, EndDate = DateTime.Now, Place = "cafe", IsDone = false }; var resultItem = new ToDoItemDto { Title = "meet in cafe" }; _mapperMock.Setup(x => x.Map <ToDoItemDto>(item)).Returns(resultItem); _repositoryMock.Setup(r => r.GetAll()).Returns(new List <ToDoItem> { item }.AsQueryable <ToDoItem>()); //Act var todoItemDto = _service.GetToDoItems(filter); //Assets Assert.AreEqual(item.Title, todoItemDto.rows.FirstOrDefault().Title); }
/// <summary> /// Just for testing! Fills in memory db context /// </summary> public static void FillInMemoryDbContext(ToDoDbContext toDoDbContext) { var newTodo1 = new ToDoItem() { Created = DateTime.Now.AddMinutes(-353), Description = "Do what you have to do", Title = "Code new feature - in memory test", Id = Guid.NewGuid() }; var todo1Entity = toDoDbContext.ToDoItems.Add(newTodo1); var pomodoroItem = new PomodoroItem { DateTimeInUtc = DateTime.Now.AddMinutes(-12), ToDoItem = todo1Entity.Entity, LengthInSec = 15 * 60, }; toDoDbContext.PomodoroItems.Add(pomodoroItem); toDoDbContext.SaveChanges(); int aa = toDoDbContext.ToDoItems.ToList().Count; }
public IActionResult Create([FromBody] ToDoItem item) { if (item == null || !ModelState.IsValid) { return(BadRequest(ErrorCodeEnum.TodoItemNameAndDescriptionRequired.ToString())); } try { if (_toDoRepository.DoesItemExist(item.Id)) { return(StatusCode(StatusCodes.Status409Conflict, ErrorCodeEnum.TodoItemIdInUse.ToString())); } _toDoRepository.Insert(item); } catch (Exception) { // TODO add logger return(BadRequest(ErrorCodeEnum.CouldNotCreateItem.ToString())); } return(Ok(item)); }
// </GetCompletedToDoItems> // <CompleteToDoItem> /// <summary> /// </summary> /// <returns></returns> public async static Task CompleteToDoItem(ToDoItem item) { item.Completed = true; await UpdateToDoItem(item); }
public void EditDescription(ToDoItem todo) { _repo.EditDescription(todo); }
public Task <int> DeleteItemAsync(ToDoItem item) { return(database.DeleteAsync(item)); }
//rename public void RenameToDoItem(ToDoItem toDoForRename, String newName) { toDoForRename.ItemName = newName; }
public async Task CreateAsync(ToDoItem item) { await _context.ToDoItems.AddAsync(item); }
protected override void OnInit() { this.NewItem = new ToDoItem(); }
/// <summary> /// Deletes an item from the list. /// </summary> /// <param name="item"></param> public void Delete(ToDoItem item) { camp.Call(@"/todos/delete_item/" + item.ID); if (Changed != null) Changed(this, EventArgs.Empty); }
// Remove a to-do task item from the database and collections. public void DeleteToDoItem(ToDoItem toDoForDelete) { // Remove the to-do item from the data context. toDoDBContext.Items.DeleteOnSubmit(toDoForDelete); // Save changes to the database. toDoDBContext.SubmitChanges(); if (TodayToDoItems.Contains(toDoForDelete)) { TodayToDoItems.Remove(toDoForDelete); } else if (TomorrowToDoItems.Contains(toDoForDelete)) { TomorrowToDoItems.Remove(toDoForDelete); } else if (LaterToDoItems.Contains(toDoForDelete)) { LaterToDoItems.Remove(toDoForDelete); } }
public void ChangeCompletedStatus(ToDoItem item, bool completed) { toDoDBContext.SubmitChanges(); if (item == null) { return; } if (TodayToDoItems.Contains(item)) { TodayToDoItems.Remove(item); } else if (TomorrowToDoItems.Contains(item)) { TomorrowToDoItems.Remove(item); } else if (LaterToDoItems.Contains(item)) { LaterToDoItems.Remove(item); } CompletedToDoItems.Insert(0, item); }
public async Task CheckItem (ToDoItem item) { if (client == null) { return; } // Set the item as completed and update it in the table item.Complete = true; try { await toDoTable.UpdateAsync (item); if (item.Complete) adapter.Remove (item); } catch (Exception e) { CreateAndShowDialog (e, "Error"); } }
public async void AddItem (View view) { if (client == null || string.IsNullOrWhiteSpace (textNewToDo.Text)) { return; } // Create a new item var item = new ToDoItem { Text = textNewToDo.Text, Complete = false }; try { // Insert the new item await toDoTable.InsertAsync (item); if (!item.Complete) { adapter.Add (item); } } catch (Exception e) { CreateAndShowDialog (e, "Error"); } textNewToDo.Text = ""; }
/// <summary> /// Move an item to a different list. /// </summary> /// <param name="item">The item to move.</param> /// <param name="list">The list that should receive the item.</param> public static void MoveItem(ToDoItem item, ToDoList list) { if (item.List == null) throw new ArgumentException("The item is not part of any list."); ToDoItem newItem = list.Add(item.Content); newItem.PersonID = item.PersonID; item.List.Delete(item); }
public void Post(ToDoItem todo) { Thread.Sleep(3000); todo.ID = MockData.Count > 0 ? MockData.Keys.Max() + 1 : 1; MockData.Add(todo.ID, todo); }
// Write changes in the data context to the database. public void UpdateToDoItem(ToDoItem newItem) { ToDoItem oldItem = toDoDBContext.Items.Single(item => item.Id == newItem.Id); oldItem.IsCompleted = newItem.IsCompleted; oldItem.Note = newItem.Note; oldItem.Priority = newItem.Priority; oldItem.RemindTime = newItem.RemindTime; oldItem.Title = newItem.Title; oldItem.Remind = newItem.Remind; toDoDBContext.SubmitChanges(); }
private void EditItem(ToDoItem obj) { _nav.NavigateTo <TodoAddViewModel>(obj); }
// Add a to-do item to the database and collections. public void AddToDoItem(ToDoItem newToDoItem, string group) { // Add a to-do item to the data context. toDoDBContext.Items.InsertOnSubmit(newToDoItem); // Save changes to the database. toDoDBContext.SubmitChanges(); if (group == null) { return; } if (group.Equals(CreateItemControl.TOMORROW)) { TomorrowToDoItems.Insert(0, newToDoItem); } else if (group.Equals(CreateItemControl.LATER)) { LaterToDoItems.Insert(0, newToDoItem); } else // add to today as default { // Add a to-do item to the "all" observable collection. TodayToDoItems.Insert(0, newToDoItem); } }
public Task <bool> AddItemAsync(ToDoItem newItem) { throw new Exception(); }
public void OnGUI() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.Width(200)); GUILayout.Label("Azure End Point"); AzureEndPoint = GUILayout.TextField(AzureEndPoint, GUILayout.Width(200)); GUILayout.Label("Application Key"); ApplicationKey = GUILayout.TextField(ApplicationKey, GUILayout.Width(200)); GUILayout.Label("Facebook Access Token"); FacebookAccessToken = GUILayout.TextField(FacebookAccessToken, GUILayout.Width(200)); if (GUILayout.Button("Log In")) Login(); GUILayout.EndVertical(); GUI.enabled = (azure != null && azure.User != null); GUILayout.BeginVertical(GUILayout.Width(200)); GUILayout.TextField(""+_todo.Id); _todo.Text = GUILayout.TextField(_todo.Text); if(GUILayout.Button("Add")) { // Note: You don't need to do the following, // it's done in the insert method. // _todo.Id = null; azure.Insert<ToDoItem>(_todo); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(200)); if (GUILayout.Button("Query/Where")) { _toDoItems.Clear(); azure.Where<ToDoItem>( p => p.Text == "Some Text", ReadHandler); } if (GUILayout.Button("List All")) { GetAllItems(); } GUILayout.Label("Item count: " + _toDoItems.Count); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Height(300)); GUILayout.BeginVertical(); foreach (var item in _toDoItems) { GUILayout.BeginHorizontal(); if (GUILayout.Button(">", GUILayout.Width(20), GUILayout.Height(20))) { _selectedItem = item; } GUILayout.Label(item.Text); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(200)); var was = GUI.enabled; GUI.enabled = _selectedItem.Id != null; GUILayout.Label("ID:" + _selectedItem.Id); _selectedItem.Text = GUILayout.TextField(_selectedItem.Text); _selectedItem.Complete = GUILayout.Toggle(_selectedItem.Complete, "Complete"); if (GUILayout.Button("Update")) { azure.Update<ToDoItem>(_selectedItem); } if (GUILayout.Button("Delete")) { azure.Delete<ToDoItem>(_selectedItem); } GUI.enabled = was; GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.enabled = true; }
public void HandleAddClick() { stateManager.AddItem(NewItem); NewItem = new ToDoItem(); }
public void UpdateTask(string list, ToDoItem value) { value.List = _uow.ToDoLists.GetFirst(l => l.Id == list); _uow.ToDoItems.Update(value); _uow.Commit(); }
public void Updated(ToDoItem item) { _context.TodoItems.Update(item); Save(); }
public ToDoListEventArgs(ToDoItem item) { Item = item; }
public void Add(ToDoItem todo) { _toDoContext.ToDoItem.Add(todo); _toDoContext.SaveChanges(); }
public void ToDoItemRepository_Update_ShouldReturnUpdatedEntity() { var list = new Order(); var itemToChange = new ToDoItem() { Id = 1, DateAdded = DateTime.MinValue, DateCompletion = default(DateTime), IsCompleted = false, IsFavourited = false, List = list, Note = "note", Text = "text" }; var dbData = new List<ToDoItem>() { itemToChange, new ToDoItem() { Id = 2, DateAdded = DateTime.MinValue, DateCompletion = default(DateTime), IsCompleted = false, IsFavourited = false, List = new Order(), Note = "note", Text = "text" }, new ToDoItem() { Id = 3, DateAdded = DateTime.MinValue, DateCompletion = default(DateTime), IsCompleted = false, IsFavourited = false, List = new Order(), Note = "note", Text = "text" } }.AsQueryable(); var newItem = new ToDoItem() { Id = 1, DateAdded = DateTime.MinValue, DateCompletion = default(DateTime), IsCompleted = false, IsFavourited = false, List = null, Note = "note1", Text = "text1" }; var dbSetMock = new Mock<DbSet<ToDoItem>>(); dbSetMock.As<IQueryable<ToDoItem>>().Setup(x => x.Provider).Returns(dbData.Provider); dbSetMock.As<IQueryable<ToDoItem>>().Setup(x => x.Expression).Returns(dbData.Expression); dbSetMock.As<IQueryable<ToDoItem>>().Setup(x => x.ElementType).Returns(dbData.ElementType); dbSetMock.As<IQueryable<ToDoItem>>().Setup(x => x.GetEnumerator()).Returns(dbData.GetEnumerator()); var dbContextMock = new Mock<ApplicationDbContext>(); dbContextMock.Setup(x => x.Set<ToDoItem>()).Returns(dbSetMock.Object); var repo = new ToDoItemRepository(dbContextMock.Object); var result = repo.Update(newItem); Assert.AreEqual(newItem.Text, result.Text); Assert.AreEqual(newItem.DateCompletion, result.DateCompletion); Assert.AreEqual(newItem.Note, result.Note); Assert.AreEqual(newItem.IsCompleted, result.IsCompleted); Assert.AreSame(result.List, list); }
public void InsertTodoItem(ToDoItem toDoItem) { _repo.InsertTodoItem(toDoItem); }
private void ListenToItem(ToDoItem item, bool listen) { if (item == null) return; if (listen) { item.PositionChanged += new EventHandler(item_PositionChanged); item.PersonChanged += new EventHandler(item_PersonChanged); item.CompletedChanged += new EventHandler(item_CompletedChanged); } else { item.PositionChanged -= new EventHandler(item_PositionChanged); item.PersonChanged += new EventHandler(item_PositionChanged); item.CompletedChanged -= new EventHandler(item_CompletedChanged); } }
public AddToDoItem(ToDoItem item) { this.item = item; }
bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType) { var scheme = "hybrid:"; // If the URL is not our own custom scheme, just let the webView load the URL as usual if (request.Url.Scheme != scheme.Replace(":", "")) return true; // This handler will treat everything between the protocol and "?" // as the method name. The querystring has all of the parameters. var resources = request.Url.ResourceSpecifier.Split('?'); var method = resources [0]; var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]); // breaks if ? not present (ie no params) if (method == "") { var template = new iProPQRSPortableLib.ToDoView () { Model = new ToDoItem() }; var page = template.GenerateString (); webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl); } else if (method == "ViewTask") { var id = parameters ["todoid"]; //var model = App.Database.GetItem (Convert.ToInt32 (id)); var model = new ToDoItem{ Name = "Test"}; var template = new ToDoView () { Model = model }; var page = template.GenerateString (); webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl); } else if (method == "TweetAll") { //var todos = App.Database.GetItemsNotDone (); var totweet = ""; // foreach (var t in todos) // totweet += t.Name + ","; if (totweet == "") totweet = "there are no tasks to tweet"; else totweet = "Still do to:" + totweet; var tweetController = new TWTweetComposeViewController (); tweetController.SetInitialText (totweet); PresentViewController (tweetController, true, null); } else if (method == "TextAll") { if (MFMessageComposeViewController.CanSendText) { //var todos = App.Database.GetItemsNotDone (); var totext = ""; // foreach (var t in todos) // totext += t.Name + ","; if (totext == "") totext = "there are no tasks to text"; MFMessageComposeViewController message = new MFMessageComposeViewController (); message.Finished += (sender, e) => { e.Controller.DismissViewController (true, null); }; //message.Recipients = new string[] { receiver }; message.Body = totext; PresentViewController (message, true, null); } else { new UIAlertView ("Sorry", "Cannot text from this device", null, "OK", null).Show (); } } else if (method == "ToDoView") { // the editing form var button = parameters ["Button"]; if (button == "Save") { var id = parameters ["id"]; var name = parameters ["name"]; var notes = parameters ["notes"]; var done = parameters ["done"]; // var todo = new ToDoItem { // ID = Convert.ToInt32 (id), // Name = name, // Notes = notes, // Done = (done == "on") // }; //App.Database.SaveItem (todo); NavigationController.PopToRootViewController (true); } else if (button == "Delete") { var id = parameters ["id"]; //App.Database.DeleteItem (Convert.ToInt32 (id)); NavigationController.PopToRootViewController (true); } else if (button == "Cancel") { NavigationController.PopToRootViewController (true); } else if (button == "Speak") { var name = parameters ["name"]; var notes = parameters ["notes"]; //Speech.Speak (name + " " + notes); } } return false; // var template = new ToDoView () { Model = new TodoItem() }; // var page = template.GenerateString (); // webView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl); // var jsAlert = "alert('test')"; // webView.EvaluateJavascript (jsAlert); // return false; }
public int GetNextStepRank(ToDoItem item) { return(item.ToDoItemSteps.OrderByDescending(tdis => tdis.Rank).FirstOrDefault()?.Rank + 1 ?? 1); }
public async Task AddAsync(ToDoItem item) { _db.ToDoItems.Add(item); await _db.SaveChangesAsync(); }
private static ToDoItemDTO ItemToDTO(ToDoItem todoItem) => new()
public ApiPostToDoItem(ToDoItem item) { this.item = item ?? throw new ArgumentNullException(nameof(item)); }
public ToDoItemCompletedEvent(ToDoItem completedItem) { CompletedItem = completedItem; }
/// <summary> /// removes done items from the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void removeButton_Click(object sender, RoutedEventArgs e) { /// this item is used to search the collection if there are items marked as done /////////////The constructor is designed to be used for such cases//////////// ToDoItem searchItem = new ToDoItem("", true); //as defined in the ToDoItem class the key for searching is the Property ToDoItem.done ///////////////////////////////////////// ////I just wanted to display message, ignoring the returned value. // when there are no marked items but collection contains some items if (!m_ToDoItems.Contains(searchItem) && m_ToDoItems.Count != 0) { MessageBoxResult result2 = MessageBox.Show("Please Mark an Item As Done", "No Items to Remove!", MessageBoxButton.OK); } //collection contains no items else if (m_ToDoItems.Count == 0) { MessageBoxResult result1 = MessageBox.Show("Please Enter an Item", "No Items to Remove!", MessageBoxButton.OK); } for (int i = 0; i < m_ToDoItems.Count; ) { if (m_ToDoItems[i].Done) { m_ToDoItems.RemoveAt(i); i = 0;// after removing there will be an updated list with a current size(count) //so the index should start over again } else { ++i;// when no item is removed, index is incremented since the list is not changed. } } }