public async Task <ActionResult> Insert([FromBody] R_Viaje_Viajero relacional) { if (relacional == null || relacional.Viaje < 1 || relacional.Viajero < 1) { return(BadRequest()); } try { R_Viaje_Viajero validacion = _context.Viajes_Viajeros.Where(p => p.Viaje == relacional.Viaje && p.Viajero == relacional.Viajero && p.Eliminado == null).FirstOrDefault(); if (validacion != null) { return(Conflict()); } relacional.Id = 0; relacional.Creado = DateTime.Now; relacional.Modificado = relacional.Creado; relacional.Eliminado = null; _context.Add(relacional); await _context.SaveChangesAsync(); return(Created(Request.Path.ToString() + "/" + relacional.Id.ToString(), relacional)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
private void timer1_Tick(object sender, EventArgs e) { var currentUser = LoginForm.LoggedUser.Id; var use = _context.Users.FirstOrDefault(c => c.Id == currentUser); var resultGame = new Statistic { Created = _start, GameType = GameType.NumberFindGame, SuccessCount = _successCount, User = use, WrongCount = _wrongCount }; if (timerLeft > 0) { timerLeft--; Timer.Text = timerLeft.ToString(); } if (timerLeft == 0) { timer1.Stop(); MessageBox.Show(Timer.Text = "Успешные ходы : " + _successCount + "\nНеуспешные : " + _wrongCount); _context.Add(resultGame); _context.SaveChanges(); Close(); } }
private void Timer_tick(object sender, EventArgs e) { if (_timerLeft > 0) { _timerLeft--; Timer.Text = _timerLeft.ToString(); } if (_timerLeft == 0) { time.Stop(); var currentUser = LoginForm.LoggedUser.Id; var use = _context.Users.FirstOrDefault(c => c.Id == currentUser); var resultGame = new Statistic { Created = _start, GameType = GameType.FindEvenAndOddNumbers, SuccessCount = _even, User = use, WrongCount = _odd }; _context.Add(resultGame); _context.SaveChanges(); MessageBox.Show(Timer.Text = " Четные : " + _even + "\n Нечетные : " + _odd); Close(); } }
public async Task UploadTemplate(DefaultContext context, string name, User user, Stream stream, long length, Action <double> callback = null) { await context.Database.BeginTransactionAsync(); var hypervisor = await context.Hypervisors.FirstOrDefaultAsync(); context.Entry(user).State = EntityState.Unchanged; var vmTemplate = new VmTemplate { Name = name, Owner = user, IsCoreRouter = false, }; context.Add(vmTemplate); await context.SaveChangesAsync(); var templateId = await UploadVmTemplate( name, stream, length, hypervisor, vmTemplate, callback); var primaryHypervisorNode = await ProxmoxManager.GetPrimaryHypervisorNode(hypervisor); vmTemplate.HypervisorVmTemplates = new List <HypervisorVmTemplate> { new HypervisorVmTemplate { HypervisorNode = primaryHypervisorNode, TemplateVmId = templateId } }; await context.SaveChangesAsync(); context.Database.CommitTransaction(); }
public async Task <ActionResult> Insert([FromBody] Viaje viaje) { if (viaje == null) { return(BadRequest()); } try { Viaje validacion = _context.Viajes.Where(p => p.Codigo == viaje.Codigo && p.Eliminado == null).FirstOrDefault(); if (validacion != null) { return(Conflict()); } viaje.Id = 0; viaje.Creado = DateTime.Now; viaje.Modificado = viaje.Creado; viaje.Eliminado = null; _context.Add(viaje); await _context.SaveChangesAsync(); return(Created(Request.Path.ToString() + "/" + viaje.Id.ToString(), viaje)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
private void CheckForWinner() { for (var i = 0; i < tableLayoutPanel1.Controls.Count; i++) { var label = tableLayoutPanel1.Controls[i] as Label; if (label != null && label.ForeColor == label.BackColor) { return; } } var currentUser = LoginForm.LoggedUser.Id; var use = _context.Users.FirstOrDefault(c => c.Id == currentUser); var resultGame = new Statistic { Created = _start, GameType = GameType.CoubeGameLevel2, SuccessCount = _successCount, User = use, WrongCount = _wrongCounter }; var finishText = $"Успешные завершений: {_successCount} :: Неправильные: {_wrongCounter}"; _context.Add(resultGame); _context.SaveChanges(); MessageBox.Show(finishText); Close(); }
public async Task <ActionResult> Insert([FromBody] Viajero viajero) { if (viajero == null || string.IsNullOrEmpty(viajero.Cedula) || string.IsNullOrEmpty(viajero.Nombres) || string.IsNullOrEmpty(viajero.Apellidos)) { return(BadRequest()); } try { Viajero validacion = _context.Viajeros.Where(p => p.Cedula == viajero.Cedula && p.Eliminado == null).FirstOrDefault(); if (validacion != null) { return(Conflict()); } viajero.Id = 0; viajero.Creado = DateTime.Now; viajero.Modificado = viajero.Creado; viajero.Eliminado = null; _context.Add(viajero); await _context.SaveChangesAsync(); return(Created(Request.Path.ToString() + "/" + viajero.Id.ToString(), viajero)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
private void doneButton_Click(object sender, EventArgs e) { doneButton.Enabled = false; startButton.Enabled = true; timer1.Stop(); int resultPlus = A + B; int resultMinus = A - B; var currentUser = LoginForm.LoggedUser.Id; var use = _context.Users.FirstOrDefault(c => c.Id == currentUser); var resultGame = new Statistic { Created = _start, GameType = GameType.MathTImeGame, User = use, }; if (answerPlusBox.Text == resultPlus.ToString() && AnswerMinusBox.Text == resultMinus.ToString()) { timer1.Stop(); timerLabel.Text = "Вы выиграли!"; answerPlusBox.Text = ""; AnswerMinusBox.Text = ""; _context.Add(resultGame); _context.SaveChanges(); Hide(); } else { timerLabel.Text = "Вы проиграли"; } }
public bool SaveMoreInfo([FromBody] Contact contact) { using DefaultContext ctx = new DefaultContext(); ctx.Add(contact); ctx.SaveChanges(); return(true); }
public async Task <IActionResult> Create([Bind("ProjectId,Name,Project_Adress,Uploaded_Date,StudentId,TeacherId")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(project)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Region region) { if (ModelState.IsValid) { _context.Add(region); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(region)); }
public async Task <IActionResult> Create([Bind("DisciplineId,Title")] Discipline discipline) { if (ModelState.IsValid) { _context.Add(discipline); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(discipline)); }
public async Task <IActionResult> Create([Bind("StudentId,Password,Username,StudentName,Group,Field,Year")] Student student) { if (ModelState.IsValid) { _context.Add(student); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(student)); }
public async Task <IActionResult> Create([Bind("Id,Original,Regional,UserId,RegionId")] Expression expression) { if (ModelState.IsValid) { _context.Add(expression); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(expression)); }
public async Task <IActionResult> Create(BlogModel model) { if (ModelState.IsValid) { DB.Add(model); await DB.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <IActionResult> Create([Bind("Id,Title,Content,CreateTime,CreateUser,Status")] BlogModel blogModel) { if (ModelState.IsValid) { _context.Add(blogModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(blogModel)); }
public async Task <IActionResult> Create([Bind("TeacherId,Password,Username,TeacherName,Subject")] Teacher teacher) { if (ModelState.IsValid) { _context.Add(teacher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(teacher)); }
public async Task <IActionResult> Create([Bind("Id,UserId,ExpressionId")] Vote vote) { if (ModelState.IsValid) { _context.Add(vote); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vote)); }
public async Task <IActionResult> CreateStagiaire([Bind("MatriculeStagiaire,DateNaissanceStagiaire,IdPersonne,NomPersonne,PrenomPersonne,CivilitePersonne,SexePersonne,AdresseMail,CatPersonne")] Stagiaire stagiaire) { if (ModelState.IsValid) { _context.Add(stagiaire); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(stagiaire)); }
public async Task <IActionResult> Create([Bind("Id,Login,Password,RoleId,RegDate,IsBlocked")] UsersModel usersModel) { if (ModelState.IsValid) { _context.Add(usersModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(usersModel)); }
public async Task <IActionResult> Create([Bind("Id,Name,DateDeSortie,Stock,GenreId")] Movie movie) { if (ModelState.IsValid) { _context.Add(movie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenreId"] = new SelectList(_context.Genres, "Id", "Name", movie.GenreId); return(View(movie)); }
public async Task <IActionResult> Create([Bind("Id,Name,Birthday,IsSubscribedToNewsletter,AdhesionId")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AdhesionId"] = new SelectList(_context.Adhesions, "Id", "Name", customer.AdhesionId); return(View(customer)); }
public async Task <IActionResult> Create([Bind("Id,Text,TourId")] SchedulesModel schedulesModel) { if (ModelState.IsValid) { _context.Add(schedulesModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TourId"] = new SelectList(_context.Tours, "Id", "Id", schedulesModel.TourId); return(View(schedulesModel)); }
public async Task <IActionResult> Create([Bind("Id,Title,IsSpecial,IsTour,IsBustour,IsCruise,CategoryId")] FiltersModel filtersModel) { if (ModelState.IsValid) { _context.Add(filtersModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", filtersModel.CategoryId); return(View(filtersModel)); }
public IActionResult Post(Customer customer) { try { _dbContext.Add(customer); _dbContext.SaveChanges(); return CreatedAtRoute(nameof(GetById), new { customer.Id }, null); } catch (Exception) { return BadRequest(); } }
public async Task <IActionResult> Create( [Bind("Id,Notes,Latitude,Longitude,LocationOverride,WeatherSummary,Date")] JournalEntry journalEntry) { if (ModelState.IsValid) { _context.Add(journalEntry); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(journalEntry)); }
public void button1_Click(object sender, EventArgs e) { var anotherDelayTime = delayTime - (level * 500); var timer = new System.Windows.Forms.Timer { Enabled = true, Interval = anotherDelayTime <= 2000 ? 2000 : anotherDelayTime }; timer.Tick += (o, a) => { timer.Stop(); label1.Hide(); }; string text = textBox1.Text; var currentUser = LoginForm.LoggedUser.Id; var use = _context.Users.FirstOrDefault(c => c.Id == currentUser); var resultGame = new Statistic { Created = start, GameType = GameType.StringGame, SuccessCount = level, User = use, WrongCount = wrongCounter }; if (start < DateTime.Now) { var finishText = $"Вы прошли уровень!: {level} :: Неправильне : {wrongCounter}"; MessageBox.Show(finishText); label1.Text = finishText; button1.Enabled = false; textBox1.Enabled = false; label1.Show(); timer.Enabled = false; _context.Add(resultGame); _context.SaveChanges(); Close(); } else if ((randomText == text.ToUpper())) { ++textLength; ++level; randomText = RandomString(textLength); label1.Text = randomText; textBox1.Text = randomText; label1.Show(); } else { wrongCounter++; randomText = RandomString(textLength); label1.Text = randomText; textBox1.Text = randomText; label1.Show(); } }
public async Task <IActionResult> Create([Bind("Title,Image,FilterId")] FilterAllowablesModel filterAllowablesModel, IFormFile imageFile) { //if (imageFile != null) // filterAllowablesModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); if (ModelState.IsValid) { _context.Add(filterAllowablesModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index), new { id = filterAllowablesModel.FilterId })); } ViewData["FilterId"] = new SelectList(_context.Filters, "Id", "Title"); ViewBag.Filter = _context.Filters.Find(filterAllowablesModel.FilterId); return(View(filterAllowablesModel)); }
public IActionResult createUser(Usuario user) { try { db.Add(user); db.SaveChanges(); } catch (Exception e) { // I'll think about a more meaningful error later return(StatusCode(500)); } return(Ok()); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,ShortDescription,Image,UrlRus")] CategoriesModel categoriesModel, IFormFile imageFile) { if (imageFile != null) { categoriesModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); } if (ModelState.IsValid) { _context.Add(categoriesModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoriesModel)); }