Пример #1
0
        public ActionResult AddTeams(AddTeamsModel result)
        {
            Folder Folder = reposetory.GetFolder(result.Folder.FolderID);
            Association assocoation = reposetory.GetAssociation(CurrentProfile.AssociationID);
            result.Folder = Folder;
            result.LocationsSelectList = reposetory.GetAssociation(CurrentProfile.AssociationID).Locations.Select(d => new SelectListItem { Value = d.LocationID.ToString(), Text = d.Name }).ToList();
            DateTime start = result.StartDate.Date.Add(result.StartTime.TimeOfDay);
            if (ModelState.ContainsKey("Folder.FoldereName")) ModelState["Folder.FoldereName"].Errors.Clear();
            if (start < Folder.Start | start > Folder.Finish) ModelState.AddModelError("", General.ErrorStartNotWithinFolderDate);
            if (result.Duration == new TimeSpan(0, 0, 0)) ModelState.AddModelError("", General.ErrorDurationZero);

            if (ModelState.IsValid)
            {
                Location Loc = reposetory.GetLocation(result.Location);
                for (int i = 0; (int)result.Repetition <= 0 ? i < 1 : start.AddDays(i) < Folder.Finish; i += (int)result.Repetition <= 0 ? 1 : (int)result.Repetition)
                {
                    Team team = new Team
                    {
                        Start = start.AddDays(i),
                        Duration = result.Duration,
                        Location = Loc,
                        Status = TeamStatus.Planned,
                        Association = assocoation
                    };
                    Folder.Teams.Add(team);
                }

                if (reposetory.SaveFolder(Folder)) return RedirectToAction("Folder", null, new { ID = Folder.FolderID });
            }
            return View(result);
        }
Пример #2
0
        public ActionResult AddTeams(Guid Id)
        {
            AddTeamsModel result = new AddTeamsModel
            {
                Folder = reposetory.GetFolder(Id),
                LocationsSelectList = reposetory.GetAssociation(CurrentProfile.AssociationID).Locations.Select(d => new SelectListItem { Value = d.LocationID.ToString(), Text = d.Name }).ToList()
            };
            result.StartDate = result.StartTime = result.Folder.Start.Date.AddHours(23).AddMinutes(30);
            result.Duration = new TimeSpan(4, 0, 0);


            return View(result);
        }