예제 #1
0
        public ActionResult Create(HttpPostedFileBase file_upload, FormCollection collection)
        {
            ImagePaths photoPaths = null;
            ImageDimensions imgDims = null;
            ImagePaths thumbNailPaths = null;

            try
            {
                photoPaths = SaveUploadedFile(file_upload);
                imgDims = ImageHandler.GetImageDimensions(photoPaths.FilePath);

                //Save file
                var photo = new Photo();
                photo.PhotoUrl = photoPaths.SqlAddress;
                if (imgDims != null)
                {
                    photo.Width = imgDims.Width;
                    photo.Height = imgDims.Height;
                }
                var photoRepo = new PhotoRepository();
                photoRepo.Save(photo);

                var team = new Team {TeamName = collection.Get("TeamName")};

                //Save Location
                var locationRepo = new LocationRepository();
                var location = new Location();
                location.City = collection.Get("City");
                location.StateId = Convert.ToInt32(collection.Get("StateId"));
                locationRepo.Add(location);

                team.LocationId = location.LocationId;
                team.PhotoId = photo.PhotoId;

                this.repo.Add(team);

                return RedirectToAction("Index");
            }
            catch
            {
                ViewBag.States = this.GetStates();
                return View();
            }
        }
예제 #2
0
        private void FixupTeam1(Team previousValue)
        {
            if (previousValue != null && previousValue.Games1.Contains(this))
            {
                previousValue.Games1.Remove(this);
            }

            if (Team1 != null)
            {
                if (!Team1.Games1.Contains(this))
                {
                    Team1.Games1.Add(this);
                }
                if (TeamId != Team1.TeamId)
                {
                    TeamId = Team1.TeamId;
                }
            }
        }
예제 #3
0
        private void FixupTeam(Team previousValue)
        {
            if (previousValue != null && previousValue.TicketPrices.Contains(this))
            {
                previousValue.TicketPrices.Remove(this);
            }

            if (Team != null)
            {
                if (!Team.TicketPrices.Contains(this))
                {
                    Team.TicketPrices.Add(this);
                }
                if (TeamId != Team.TeamId)
                {
                    TeamId = Team.TeamId;
                }
            }
        }