public async Task <IActionResult> PutTodoitems([FromRoute] long id, [FromBody] Todoitems todoitems) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != todoitems.Id) { return(BadRequest()); } _context.Entry(todoitems).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoitemsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostTodoitems([FromBody] Todoitems todoitems) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Todoitems.Add(todoitems); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTodoitems", new { id = todoitems.Id }, todoitems)); }
public override void OnNavigatedTo(NavigationParameters parameters) #endif { IsBusy = true; switch (parameters.GetNavigationMode()) { case NavigationMode.Back: #if (UseAzureMobileClient) #if (UseMvvmHelpers) TodoItems.ReplaceRange(await _dataContext.TodoItems.ReadAllItemsAsync()); #else Todoitems.Clear(); foreach (var item in await _dataContext.TodoItems.ReadAllItemsAsync()) { TodoItems.Add(item); } #endif #elseif (UseRealm) // Do anything you want to do only when Navigating Back to the View #else if (parameters.ContainsKey("todoItem")) { TodoItems.Add(parameters.GetValue <TodoItem>("todoItem")); } #endif break; case NavigationMode.New: #if (UseAzureMobileClient) #if (UsesAuthentication) await _cloudService.LoginAsync(); #endif #if (UseMvvmHelpers) TodoItems.AddRange(await _dataContext.TodoItems.ReadAllItemsAsync()); #else foreach (var item in await _dataContext.TodoItems.ReadAllItemsAsync()) { TodoItems.Add(item); } #endif #elseif (UseRealm) TodoItems = _realm.All <TodoItem>(); #else #if (UseMvvmHelpers) TodoItems.AddRange(parameters.GetValues <string>("todo") .Select(n => new TodoItem { Name = n })); #else foreach (var item in parameters.GetValues <string>("todo")) { TodoItems.Add(new TodoItem() { Name = item }); } #endif #endif break; } IsBusy = false; }