public async Task <IActionResult> SaveNewsNoUserInformation([FromBody] NewsInformationViewModel model) { if (await _context.NewsInformationNoUserAction.AnyAsync(x => x.MirrorId == model.MirrorId)) { var newsUserDetected = await _context.NewsInformationNoUserAction.Where(x => x.MirrorId == model.MirrorId).FirstOrDefaultAsync(); newsUserDetected.Tittle = model.Tittle; newsUserDetected.Description = model.Description; newsUserDetected.MirrorId = model.MirrorId; newsUserDetected.Index = model.Index; await _context.SaveChangesAsync(); return(Ok()); } else { var newinformation = new NewsInformationNoUser() { Tittle = model.Tittle, Description = model.Description, MirrorId = model.MirrorId, Index = model.Index }; await _context.NewsInformationNoUserAction.AddAsync(newinformation); await _context.SaveChangesAsync(); return(Ok()); } //var booleanTable = await _context.BooleanTables.Where(x => x.UserId == model.UserId).FirstOrDefaultAsync(); //booleanTable.Email = true; }
public async Task <IActionResult> GetNewsNoUserInformations([FromBody] NewsInformationViewModel model) { var booleanTable = await _context.NewsInformationNoUserAction.Where(x => x.MirrorId == model.MirrorId).FirstOrDefaultAsync(); booleanTable.News = true; await _context.SaveChangesAsync(); if (!await _context.NewsInformationNoUserAction.AnyAsync(x => x.MirrorId == model.MirrorId)) { return(BadRequest("No existe este usuario en la tabla")); } var newinformation = await _context.NewsInformationNoUserAction.Where(x => x.MirrorId == model.MirrorId).FirstOrDefaultAsync(); return(Ok(newinformation)); }
public async Task <IActionResult> SetStartNewsNoUser([FromBody] NewsInformationViewModel model) { var wordsPerMinute = 200; var arreglo = model.Description.Split(' '); var contador = arreglo.Count(); var minutes = (Convert.ToDecimal(contador) / Convert.ToDecimal(wordsPerMinute)) * 60000; Thread.Sleep(Convert.ToInt32(minutes) - 1000); var booleanTable = await _context.NewsInformationNoUserAction.Where(x => x.MirrorId == model.MirrorId).FirstOrDefaultAsync(); booleanTable.StartNews = true; await _context.SaveChangesAsync(); return(Ok()); }
public async Task <IActionResult> GetNewsInformations2([FromBody] NewsInformationViewModel model) { var booleanTable = await _context.BooleanTables.Where(x => x.UserId == model.UserId).FirstOrDefaultAsync(); var newsInformation = await _context.NewsInformationAction.Where(x => x.UserId == model.UserId).FirstOrDefaultAsync(); if (!booleanTable.StartNews) { if (booleanTable.News) { booleanTable.News = false; await _context.SaveChangesAsync(); return(Ok(new { status = 1, index = newsInformation.Index })); } else { return(Ok(new { status = 2 })); } } else { booleanTable.StartNews = false; await _context.SaveChangesAsync(); return(Ok(new { status = 3 })); } }