Ejemplo n.º 1
0
        public ActionResult Upload(ImageGallery IG)
        {
            // Apply Validation Here


            if (IG.File.ContentLength > (2 * 1024 * 1024))
            {
                ModelState.AddModelError("CustomError", "File size must be less than 2 MB");
                return(View());
            }
            if (!(IG.File.ContentType == "image/jpeg" || IG.File.ContentType == "image/gif"))
            {
                ModelState.AddModelError("CustomError", "File type allowed : jpeg and gif");
                return(View());
            }

            IG.FileName  = IG.File.FileName;
            IG.ImageSize = IG.File.ContentLength;

            byte[] data = new byte[IG.File.ContentLength];
            IG.File.InputStream.Read(data, 0, IG.File.ContentLength);

            IG.ImageData = data;
            using (euroContext dc = new euroContext())
            {
                dc.ImageGalleries.Add(IG);
                dc.SaveChanges();
            }
            return(RedirectToAction("Gallery"));
        }
Ejemplo n.º 2
0
        public ActionResult Gallery()
        {
            List <ImageGallery> all = new List <ImageGallery>();

            // Here MyDatabaseEntities is our datacontext
            using (euroContext dc = new euroContext())
            {
                all = dc.ImageGalleries.ToList();
            }
            return(View(all));
        }
Ejemplo n.º 3
0
        // GET: Event
        public ActionResult Index()
        {
            List <ImageGallery> all = new List <ImageGallery>();

            // Here MyDatabaseEntities is our datacontext
            using (euroContext dc = new euroContext())
            {
                all = dc.ImageGalleries.OrderByDescending(m => m.Date.Hour).Take(1).ToList();
            }
            return(View(all));
        }
Ejemplo n.º 4
0
        // GET: Match
        // [Authorize(Roles = "Admin")]
        public ActionResult Index(string team)
        {
            euroContext       db1   = new euroContext();
            MatchesRepository db    = new MatchesRepository();
            TeamRepository    teams = new TeamRepository();
            var matches             = db.GetAllMatches().OrderBy(i => i.Date);

            ViewBag.team1 = (from t in teams.GetAllTeams()
                             select t.Name);

            var model = from r in db.GetAllMatches()
                        where r.HomeTeam.Name == team || r.GuestTeam.Name == team
                        select r;

            ViewData["MyMatches"] = matches;

            return(View(model));
        }