Beispiel #1
0
        public async Task <IActionResult> Create([Bind("ID,ActualDate,ChildName,GroupName,TrainingDay")] DateModel dateModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dateModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dateModel));
        }
        public async Task <IActionResult> Create([Bind("ID,groupName,TrainingDay,TrainingTime")] Groups groups)
        {
            if (ModelState.IsValid)
            {
                _context.Add(groups);
                await _context.SaveChangesAsync();

                groups.AddNewGroupToList(groups.groupName);
                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 }));
        }