protected override State GetStateCoreSync() { var state = base.GetStateCoreSync(); state.Todos = Todos.ToArray(); return(state); }
/// <summary> /// Removes an <see cref="iCalObject"/>-based component from all /// of the collections that this object may be contained in within /// the iCalendar. /// </summary> /// <param name="child"></param> public override void RemoveChild(iCalObject child) { base.RemoveChild(child); if (child is UniqueComponent) { UniqueComponents.Remove((UniqueComponent)child); } Type type = child.GetType(); if (type == typeof(Event) || type.IsSubclassOf(typeof(Event))) { Events.Remove((Event)child); } else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy))) { FreeBusy.Remove((FreeBusy)child); } else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal))) { Journals.Remove((Journal)child); } else if (type == typeof(DDay.iCal.Components.TimeZone) || type.IsSubclassOf(typeof(DDay.iCal.Components.TimeZone))) { TimeZones.Remove((DDay.iCal.Components.TimeZone)child); } else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo))) { Todos.Remove((Todo)child); } }
public ResponseData EditTodos(Todos todos) { ResponseData respnonse = new ResponseData(); if (ModelState.IsValid) { Todos todosreult = db.Todo.Find(todos.ID); if (todosreult != null) { todosreult.Name = todos.Name; todosreult.IsDone = todos.IsDone; db.Entry(todosreult).State = EntityState.Modified; db.SaveChanges(); respnonse.IsSuccess = true; respnonse.ResponseMessage = "Successfully updated"; } else { respnonse.IsSuccess = false; respnonse.ResponseMessage = "Unable To update"; } } else { respnonse.IsSuccess = false; respnonse.ResponseMessage = "Unable To update"; } return(respnonse); }
public static void Initialize(AngularTodoContext context) { context.Database.EnsureCreated(); // Look for any todos if (context.Todos.Any()) { return; // DB has been seeded } var todos = new Todos[] { new Todos { Id = 1, Name = "pick up mom from airport" }, new Todos { Id = 2, Name = "get groceries" }, new Todos { Id = 3, Name = "walk doggo" }, new Todos { Id = 4, Name = "buy bread" } }; foreach (Todos todo in todos) { context.Todos.Add(todo); } context.SaveChanges(); }
public async void UpdateAsync() { await _todoService.UpdateTodo(SelectedItem); Todos.Remove(SelectedItem); Todos.Add(SelectedItem); }
private async Task OnLoadTodos(object arg) { var conn = ExampleApp.NewDbConnection(); var table = conn.Table <TodoRecord>(); Todos.Reset(await table.ToListAsync()); }
public static void Main() { var initialState = new TodoAppState { DescriptionInput = "", Visibility = TodoVisibility.All, Todos = new Todo[] { new Todo { Id = 0, Description = "Learn React + Redux in C#", IsCompleted = true }, new Todo { Id = 1, Description = "Build an awesome app with them", IsCompleted = false } } }; var store = Redux.CreateStore(Todos.Reducer(initialState)); React.Render(Components.TodoItemList(store), Document.GetElementById("root")); }
/// <summary> /// Adds a new Todo-item /// </summary> /// <param name="name">Name of the new Todo-item.</param> private async Task AddTodo(string name) { // Create new todo with name, image url and empty list of tasks TodoViewModel todo = new TodoViewModel(_dialogService) { Name = name, Order = Todos.Count + 1, Tasks = new ObservableCollection<TaskViewModel>() }; // Add item to database await _repo.AddTodo(todo).ContinueWith(p => { // Get Id of added item todo.Id = p.Result; }); // Add item to collection Todos.Add(todo); // Set as the selected Todo-item SelectedTodo = todo; // Clear new todo NewTodoName = string.Empty; }
/// <summary> /// Deletes a Todo-item from the collection. /// </summary> /// <param name="todo">The Todo-item to be deleted.</param> private async Task DeleteTodo(TodoViewModel todo) { if (todo == null) return; // Delete item from database var success = await _repo.DeleteTodo(todo); // If failed, set message and return if (!success) { SetMessage("Deletion failed. Try again later."); return; } // Reset selected item SelectedTodo = null; // Remove item from view Todos.Remove(todo); // Set message SetMessage("List deleted."); // Set as deleted todo DeletedTodo = todo; // Update todo order await UpdateTodoOrder(); }
public async Task AddTodo(string todoTitle) { var todo = new Todo(Guid.NewGuid(), todoTitle); Todos.Add(todo); await Inform(); }
public async void Archive() { Todos.Where(x => x.Completed).ForEach(x => x.Archived = true); await _unitOfWork.CommitAsync(); GetTodoItems(); }
/// <summary> /// Adds an <see cref="iCalObject"/>-based component to the /// appropriate collection. Currently, the iCalendar component /// supports the following components: /// <list type="bullet"> /// <item><see cref="DDay.iCal.Components.Event"/></item> /// <item><see cref="DDay.iCal.Components.FreeBusy"/></item> /// <item><see cref="DDay.iCal.Components.Journal"/></item> /// <item><see cref="DDay.iCal.Components.TimeZone"/></item> /// <item><see cref="DDay.iCal.Components.Todo"/></item> /// </list> /// </summary> /// <param name="child"></param> public override void AddChild(iCalObject child) { base.AddChild(child); child.Parent = this; if (child is UniqueComponent) { UniqueComponents.Add((UniqueComponent)child); } Type type = child.GetType(); if (type == typeof(Event) || type.IsSubclassOf(typeof(Event))) { Events.Add((Event)child); } else if (type == typeof(FreeBusy) || type.IsSubclassOf(typeof(FreeBusy))) { FreeBusy.Add((FreeBusy)child); } else if (type == typeof(Journal) || type.IsSubclassOf(typeof(Journal))) { Journals.Add((Journal)child); } else if (type == typeof(iCalTimeZone) || type.IsSubclassOf(typeof(iCalTimeZone))) { TimeZones.Add((iCalTimeZone)child); } else if (type == typeof(Todo) || type.IsSubclassOf(typeof(Todo))) { Todos.Add((Todo)child); } }
protected void ThingGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { // store which row was clicked int selectedRow = e.RowIndex; // get the selected TodoID using the Grid's DataKey collection int TodoID = Convert.ToInt32(ThingGridView.DataKeys[selectedRow].Values["TodoID"]); // use EF and LINQ to find the selected in the DB and remove it using (TodoContext db = new TodoContext()) { // create object ot the clas and store the query inside of it Todos deleted = (from Records in db.Todos where Records.TodoID == TodoID select Records).FirstOrDefault(); // remove the selected from the db db.Todos.Remove(deleted); // save my changes back to the db db.SaveChanges(); // refresh the grid this.GetThing(); } }
public async Task <IActionResult> PutTodo(int id, Todos todo) { if (id != todo.Id) { return(BadRequest()); } _context.Entry(todo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task OnTodoCompletedAsync(TodoCompletedEvent @event) { var todo = Todos.Single(t => t.Id == @event.TodoId); todo.IsCompleted = true; await Task.CompletedTask; }
public async Task <bool> DeleteTodoAsync(Todos todo) { _context.Todos.Remove(todo); var deleted = await _context.SaveChangesAsync(); return(deleted > 0); }
public async Task Remove(Todo item) { if (item == null) { return; } //检查是否存在 var data = LoadLogs(item.ProjcectId); var todo = data.Todos.FirstOrDefault(x => x.Id == item.Id); if (data.Logs.Count(x => x.TodoId == item.Id) > 0) { //项目不为空,跳过处理 Console.WriteLine("项目不为空,不能删除。"); return; } //移除项目 Todos.Remove(todo); //移除索引 DataIndex.Todos.Remove(item.Key); await Remove(todo.Key); await Save(DataIndex); MessageAction?.Invoke(MessageTypeUpdate); }
public async Task <Todos> UpdateTodoAsync(Todos todo) { _context.Todos.Update(todo); await _context.SaveChangesAsync(); return(todo); }
public override string ToString() { string result = $"Id:{Id} Created:{CreatedAt.ToShortDateString()}\nName:{Name}\nEmail:{Email}\nAddress:{MyAddress}\n"; if (Todos != null && Todos.Count() > 0) { result += "\tToDos list:\n"; foreach (var item in Todos) { result += item.ToString(); } result += "\n"; } if (Posts != null && Posts.Count() > 0) { result += "\tPosts list:\n"; foreach (var item in Posts) { result += item.ToString(); } result += "\n"; } if (Comments != null && Comments.Count() > 0) { result += "\tComments list:\n"; foreach (var item in Comments) { result += item.ToString(); } result += "\n"; } return(result); }
private void AddTodo_Click(object sender, RoutedEventArgs e) { //set default values to be added to todo collection int userIDToPass = 1; var lastTodo = Todos.Last(); int lastTodoId = lastTodo.id += 1; bool newCompleted = false; string titleCreated = AddNewTodoField.Text; var newTodo = new Todo() { userId = userIDToPass, id = lastTodoId, title = titleCreated, completed = newCompleted }; //add to list of todos at the beginning of the list Todos.Insert(0, newTodo); //show new todo in details view SelectedTodo.Clear(); SelectedTodo.Add(newTodo); //clear searhc field AddNewTodoField.Text = ""; }
/// <summary> /// Undeletes the last known deleted Todo-item /// </summary> private async Task UndeleteTodo() { if (DeletedTodo == null) { return; } // Re-add item to database await _repo.AddTodo(DeletedTodo).ContinueWith(p => { // Get Id of added item DeletedTodo.Id = p.Result; }); // Re-add item to collection Todos.Add(DeletedTodo); // Select SelectedTodo = DeletedTodo; // Clear last deleted DeletedTodo = null; // Unset message SetMessage(null); // Update todo order await UpdateTodoOrder(); }
public async Task <ActionResult <Todos> > PostTodo(Todos todo) { _context.Todos.Add(todo); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTodo", new { id = todo.Id }, todo)); }
public async ValueTask <bool> SaveTodoList(int userId, Todo todo) { var contextTodo = await Todos.Include(x => x.TodoList) .FirstOrDefaultAsync(x => x.TodoId == todo.TodoId); if (contextTodo != null) { //need test Entry(contextTodo) .Context .Attach(todo) .State = EntityState.Modified; } else { var user = Users.Include(x => x.Todos) .First(x => x.UserId == userId); user.Todos.Add(todo); //or this case, need test // Users.First(x => x.UserId == userId) // .Todos // .Add(todo); } await SaveChangesAsync(); return(true); }
public object Get(Todos request) { ApiUser hdUser = request.ApiUser; CheckToDos(hdUser); //v1 if (!string.IsNullOrEmpty(request.key)) { request.ticket = request.key; } if (request.id.HasValue) { request.project = request.id; } //v2 var todos = request.FilteredResult <Models.Todo>(Models.Todos.GetTicketTodos(hdUser.OrganizationId, hdUser.DepartmentId, string.IsNullOrEmpty(request.ticket) ? 0 : Models.Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket), request.project ?? 0, request.all_item_types ?? false, request.assigned_id ?? 0, request.is_completed)); if (todos.Count > 0 && request.is_sub_view) { return(MakeTreeFromFlatList(todos)); } return(todos); }
public JsonResult GetTodos() { List <Todos> todos = new List <Todos>(); string connectionStr = ConfigurationManager .ConnectionStrings["connectionStr"].ConnectionString; using (SqlConnection con = new SqlConnection(connectionStr)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "spGetTodos"; cmd.CommandType = CommandType.StoredProcedure; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Todos todo = new Todos(); todo.Id = (int)rdr["Id"]; todo.Todo = (string)rdr["Todo"]; todos.Add(todo); } rdr.Close(); con.Close(); } Todos[] res = todos.ToArray(); return(this.Json(todos, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> PutTodo([FromRoute] int id, [FromBody] TodosRequest request) { int _userId = Int32.Parse(HttpContext.GetUserId()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Todos todo = await _todosService.GetTodoByIdAsync(id, _userId); if (todo == null) { return(NotFound(new { Error = new[] { "Todo not found." } })); } todo.title = request.title; todo.completed = request.completed; todo.updatedAt = DateTime.Now; var resTodo = await _todosService.UpdateTodoAsync(todo); return(Ok(resTodo)); }
protected override void GenerarSubTipos() { Todos.Add(new TipoPublicada()); Todos.Add(new TipoBorrador()); Todos.Add(new TipoPausada()); Todos.Add(new TipoFinalizada()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description")] Todos todos) { if (id != todos.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(todos); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodosExists(todos.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(todos)); }
// PUT api/Todo/5 public HttpResponseMessage PutTodos(int id, Todos todos) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != todos.Id) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(todos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
protected override void GenerarSubTipos() { Todos.Add(new TipoDocumentoDNI()); Todos.Add(new TipoDocumentoLC()); Todos.Add(new TipoDocumentoLE()); Todos.Add(new TipoDocumentoCUIT()); }
void Start(){ useStorage=true; localStorage= Window.LocalStorage; todos= new Todos(); var t = localStorage.GetItem("JsViewsTodos"); todos.Items= t!=null? Json.Parse<List<Item>>(t.ToString()): new List<Item>(); todos.Completed= todos.Items.Count(f=>f.Done); todos.Remaining= todos.Items.Count- todos.Completed; }
public void Delete(Todos request) { Repository.DeleteByIds(request.Ids); }
public object Get(Todos request) { ICollection<Todo> result = this._repository.GetAll(); return result; }
public TodoRepository Repository { get; set; } //Injected by IOC public object Get(Todos request) { return request.Ids.IsEmpty() ? Repository.GetAll() : Repository.GetByIds(request.Ids); }