Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Trainings trainings = db.Trainings.Find(id);
            int       SeasonId  = trainings.Season;
            int       TeamId    = trainings.Team;

            db.Trainings.Remove(trainings);
            db.SaveChanges();
            return(RedirectToAction("List", new { selectedseason = SeasonId, selectedteam = TeamId }));
        }
Ejemplo n.º 2
0
        // GET: Trainings/Delete/5
        public ActionResult Delete(int?id, int selectedseason, int selectedteam)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Trainings trainings = db.Trainings.Find(id);

            if (trainings == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SelectedSeason = selectedseason;
            ViewBag.SelectedTeam   = selectedteam;
            return(View(trainings));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "Id,TrainingDate,MeetDate,SigningLimitDate,TrainingLocation,Team,Season,SeasonPart,TrainingFocus,TrainingSchemeModel,TrainingLength,PublishTraining,PublishExcersises, TrainingClosed, TrainingCanceled, AttendanceClosed")] Trainings trainings)
 {
     if (ModelState.IsValid)
     {
         int SeasonId = trainings.Season;
         int TeamId   = trainings.Team;
         db.Entry(trainings).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("List", new { selectedseason = SeasonId, selectedteam = TeamId }));
     }
     ViewBag.SeasonPart          = new SelectList(db.SeasonParts, "Id", "SeasonPartName", trainings.SeasonPart);
     ViewBag.Season              = new SelectList(db.Seasons, "Id", "SeasonName", trainings.Season);
     ViewBag.Team                = new SelectList(db.Teams, "Id", "TeamName", trainings.Team);
     ViewBag.TrainingFocus       = new SelectList(db.TrainingFocuses, "Id", "TrainingFocusName", trainings.TrainingFocus);
     ViewBag.TrainingLocation    = new SelectList(db.TrainingLocations, "Id", "TrainingLocationName", trainings.TrainingLocation);
     ViewBag.TrainingSchemeModel = new SelectList(db.TrainingSchemeModels, "Id", "TrainingSchemeName", trainings.TrainingSchemeModel);
     return(View(trainings));
 }
Ejemplo n.º 4
0
        // GET: Trainings/Edit/5
        public ActionResult Edit(int?id, int selectedseason, int selectedteam)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Trainings trainings = db.Trainings.Find(id);

            if (trainings == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SeasonPart          = new SelectList(db.SeasonParts, "Id", "SeasonPartName", trainings.SeasonPart);
            ViewBag.Season              = new SelectList(db.Seasons, "Id", "SeasonName", trainings.Season);
            ViewBag.Team                = new SelectList(db.Teams, "Id", "TeamName", trainings.Team);
            ViewBag.TrainingFocus       = new SelectList(db.TrainingFocuses, "Id", "TrainingFocusName", trainings.TrainingFocus);
            ViewBag.TrainingLocation    = new SelectList(db.TrainingLocations, "Id", "TrainingLocationName", trainings.TrainingLocation);
            ViewBag.TrainingSchemeModel = new SelectList(db.TrainingSchemeModels, "Id", "TrainingSchemeName", trainings.TrainingSchemeModel);
            ViewBag.SelectedSeason      = selectedseason;
            ViewBag.SelectedTeam        = selectedteam;
            return(View(trainings));
        }
Ejemplo n.º 5
0
        // GET: Trainings/Details/5
        public PartialViewResult Details(int?id, string Viewselect)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Trainings trainings = db.Trainings.Find(id);

            if (trainings == null)
            {
                //return HttpNotFound();
            }
            ViewBag.Id = trainings.Id;

            ViewBag.CurrentPlayer = GetPlayerID(User.Identity.GetUserId());
            if (Viewselect == "Player")
            {
                return(PartialView("_PlayerDetail", trainings));
            }
            else
            {
                return(PartialView("Details", trainings));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "CurrentUser,CurrentPlayer,CurrentPlayerName,SelectedSeason,SelectedSeasonName, SelectedTeam, SelectedTeamName, DateFrom, DateTo, dayinweek, SeasonPart, TrainingLocation, TrainingFocus, TrainingSchemeModel, TrainingLength, Weekday, SigningLimitDaysAhead, TrainingTime, SigningTime, MeetTime ")] GenerateTrainings generatetrainings)
        {
            if (ModelState.IsValid)
            {
                int      interval  = 1;
                DateTime startDate = generatetrainings.DateFrom;
                DateTime stopDate  = generatetrainings.DateTo;
                while ((startDate = startDate.AddDays(interval)) <= stopDate)
                {
                    int week = Convert.ToInt32(startDate.DayOfWeek);
                    if (week == generatetrainings.dayinweek)
                    {
                        Trainings trainings = new Trainings();
                        trainings.Season = generatetrainings.SelectedSeason;
                        trainings.Team   = generatetrainings.SelectedTeam;
                        DateTime trainingdate = new DateTime(startDate.Year, startDate.Month, startDate.Day,
                                                             generatetrainings.TrainingTime.Hour, generatetrainings.TrainingTime.Minute, generatetrainings.TrainingTime.Second);
                        trainings.TrainingDate = trainingdate;
                        DateTime meetdate = new DateTime(startDate.Year, startDate.Month, startDate.Day,
                                                         generatetrainings.MeetTime.Hour, generatetrainings.MeetTime.Minute, generatetrainings.MeetTime.Second);
                        trainings.MeetDate = meetdate;
                        DateTime signindate = new DateTime(startDate.Year, startDate.Month, startDate.Day,
                                                           generatetrainings.SigningTime.Hour, generatetrainings.SigningTime.Minute, generatetrainings.SigningTime.Second);
                        signindate = signindate.AddDays(generatetrainings.SigningLimitDaysAhead);
                        trainings.SigningLimitDate    = signindate;
                        trainings.TrainingLocation    = generatetrainings.TrainingLocation;
                        trainings.SeasonPart          = generatetrainings.SeasonPart;
                        trainings.TrainingFocus       = generatetrainings.TrainingFocus;
                        trainings.TrainingLength      = generatetrainings.TrainingLength;
                        trainings.TrainingSchemeModel = generatetrainings.TrainingSchemeModel;
                        db.Trainings.Add(trainings);
                        db.SaveChanges();
                    }
                }
                return(RedirectToAction("List", "Trainings", new { selectedseason = generatetrainings.SelectedSeason, selectedteam = generatetrainings.SelectedTeam }));
            }
            ViewBag.SelectedSeason      = generatetrainings.SelectedSeason;
            ViewBag.SelectedTeam        = generatetrainings.SelectedTeam;
            ViewBag.CurrentUser         = User.Identity.GetUserId();
            ViewBag.CurrentPlayer       = GetPlayerID(User.Identity.GetUserId());
            ViewBag.CurrentPlayerName   = GetPlayerName(User.Identity.GetUserId());
            ViewBag.TrainingSchemeModel = new SelectList(db.TrainingSchemeModels, "Id", "TrainingSchemeName");
            ViewBag.SeasonPart          = new SelectList(db.SeasonParts, "Id", "SeasonPartName");
            ViewBag.TrainingLocation    = new SelectList(db.TrainingLocations, "Id", "TrainingLocationName");
            List <DayInWeek> dayinweek = new List <DayInWeek>();

            dayinweek.Insert(0, new DayInWeek {
                day = 0, dayname = "Neděle"
            });
            dayinweek.Insert(1, new DayInWeek {
                day = 1, dayname = "Pondělí"
            });
            dayinweek.Insert(2, new DayInWeek {
                day = 2, dayname = "Úterý"
            });
            dayinweek.Insert(3, new DayInWeek {
                day = 3, dayname = "Středa"
            });
            dayinweek.Insert(4, new DayInWeek {
                day = 4, dayname = "Čtvrtek"
            });
            dayinweek.Insert(5, new DayInWeek {
                day = 5, dayname = "Pátek"
            });
            dayinweek.Insert(6, new DayInWeek {
                day = 6, dayname = "Sobota"
            });
            ViewBag.DayInWeek = new SelectList(dayinweek, "day", "dayname");
            return(View(generatetrainings));
        }