private static async Task <List <RssItem> > SyncCoreAsync(LocalDbContext ctx, ISyncSource syncSource, SyncSourceInfo syncInfo, CancellationToken cancellationToken) { if (syncInfo is null) { syncInfo = new SyncSourceInfo { SyncSourceId = syncSource.SyncSourceId }; ctx.Add(syncInfo); } var page = await syncSource.TryGetItemsAsync(syncInfo.LastSyncId, cancellationToken) .ConfigureAwait(false); if (page.LastId is int lastId) { syncInfo.LastSyncId = lastId; } var newItems = page.GetItems().Select(z => { var r = new RssItem(); r.UpdateFrom(z); return(r); }).ToList(); return(ctx.AddOrIgnoreRange(newItems)); }
public async Task <IActionResult> Create([Bind("InstructorId,FirstName,LastName,EmailAddress,Course")] Instructor instructor) { if (ModelState.IsValid) { _context.Add(instructor); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(instructor)); }
public async Task <IActionResult> Create([Bind("StudentId,FirstName,LastName,EmailAddress,PhoneNumber,Course")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Create([Bind("CourseId,CourseNumber,CourseName,Description")] Course course) { if (ModelState.IsValid) { _context.Add(course); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(course)); }
public async Task <IActionResult> Create([Bind("CourseRegId,StudentId,CourseId")] StudentCourse studentCourse) { if (ModelState.IsValid) { _context.Add(studentCourse); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } IEnumerable <Course> listCourse = _context.Courses; ViewData["CourseList"] = listCourse; return(View(studentCourse)); }
public async Task <Usuario> LogInAsync() { using (var db = new LocalDbContext()) { Login login = new Login(); App.Current.Settings.GetSection("SyncUser").Bind(login); var content = new StringContent(JsonConvert.SerializeObject(login), Encoding.UTF8, JsonContentType); var response = await RequestAsync(async() => await client.PostAsync("Conta/Login", content), logIn : false); var usuario = JsonConvert.DeserializeObject <Usuario>(response); db.Usuario.RemoveRange(db.Usuario.ToList()); db.Add(usuario); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", usuario.Token); db.SaveChanges(); return(usuario); } }
public void Add(Phrase phrase) { context.Add(phrase); context.SaveChangesAsync(); }
public bool AdicionaEmpresa(Empresa empresa) { _Local.Add(empresa); _Local.SaveChanges(); return(true); }
public bool AdicionaProduto(Produtos produto) { _Local.Add(produto); _Local.SaveChanges(); return(true); }