public async Task <IActionResult> Edit(int id, [Bind("ID,groupName,TrainingDay,TrainingTime")] Groups groups) { if (id != groups.ID) { return(NotFound()); } if (ModelState.IsValid) { try { Groups item = await _context.Groups.FindAsync(groups.ID); item.groupName = groups.groupName; item.TrainingDay = groups.TrainingDay; item.TrainingTime = groups.TrainingTime; _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupsExists(groups.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(groups)); }
public async Task <IActionResult> AddPresent(int ID) { var karateKid = _context.KarateKidsAll.FirstOrDefault(x => x.ID == ID); var Today = new DateModel(karateKid.name, karateKid.Group, false); if (!_context.DateBaseAll.Where(x => x.ActualDate == DateTime.Today & x.ChildName == karateKid.name & x.ItIsPayment == false & x.GroupName == karateKid.Group).Select(x => x.ActualDate).Contains(Today.ActualDate)) { _context.Update(Today); } await _context.SaveChangesAsync(); var group = _context.Groups.Where(x => x.groupName == karateKid.Group).FirstOrDefault(); return(RedirectToAction("Index2", "KarateKids", new { groupId = group.ID })); }
public async Task <IActionResult> Edit(int id, [Bind("ID,ActualDate,ChildName,GroupName,TrainingDay")] DateModel dateModel) { if (id != dateModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dateModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DateModelExists(dateModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dateModel)); }