Esempio n. 1
0
        public ActionResult Create([Bind(Include = "Name, HeaderImage")] GameType replayGameType, int convention_id, HttpPostedFileBase headerImageFile)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (ModelState.IsValid)
            {
                if (headerImageFile != null)
                {
                    replayGameType.HeaderImage = azure.GetFileName(headerImageFile);
                }
                convention.GameTypes.Add(replayGameType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(replayGameType));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Name,Description,ExtendedDescription,Image,Url")] Guest replayGuest, HttpPostedFileBase upload, int convention_id, string categories)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (ModelState.IsValid)
            {
                replayGuest.Image = azure.GetFileName(upload);
                convention.Guests.Add(replayGuest);
                replayGuest.GuestTypes = new List <GuestType>();
                foreach (var id in categories.Split(','))
                {
                    if (int.TryParse(id, out int Id))
                    {
                        replayGuest.GuestTypes.Add(db.GuestTypes.Find(Id));
                    }
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            Console.WriteLine("fire");
            return(View(replayGuest));
        }
Esempio n. 3
0
        public Convention ResetGames(int id)
        {
            // claims all orphaned rows to whatever convention id is here
            var us   = new UserService((ClaimsIdentity)User.Identity, db);
            var user = us.GetUser();

            if (!user.isSuperAdmin)
            {
                return(null);
            }
            var convention = db.Conventions.Find(id);

            if (convention == null)
            {
                return(null);
            }

            var games = convention.Games.ToList();

            foreach (var game in games)
            {
                game.AtConvention = false;
                game.GameLocations.Clear();
            }
            db.SaveChanges();

            return(convention);
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "Name,Url,Image")] Sponsor sponsor, int convention_id, HttpPostedFileBase upload)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (ModelState.IsValid)
            {
                sponsor.Image = azure.GetFileName(upload);
                convention.Sponsors.Add(sponsor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sponsor));
        }
        public UserService(ClaimsIdentity claimsIdentity, ReplayFXDbContext context)
        {
            db = context;

            var email = claimsIdentity.Claims.Where(c => c.Type.Contains("email")).FirstOrDefault().Value;
            var auth0 = claimsIdentity.Claims.Where(c => c.Type.Contains("nameidentifier")).FirstOrDefault().Value;
            var name  = claimsIdentity.Claims.Where(c => c.Type.Contains("nickname")).FirstOrDefault().Value;

            user = db.AppUsers.Where(u => u.Email == email).FirstOrDefault();
            if (user == null)
            {
                user             = new AppUser();
                user.Email       = email;
                user.Auth0       = auth0;
                user.DisplayName = name;

                db.AppUsers.Add(user);
                db.SaveChanges();
            }
            if (!db.AppUsers.Any(u => u.isSuperAdmin == true))
            {
                user.isSuperAdmin = true;
                db.SaveChanges();
            }
        }
Esempio n. 6
0
        public List <Post> AddPost(int convention_id, PostUpload post)
        {
            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            if (String.IsNullOrEmpty(post.Text))
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            us = new UserService((ClaimsIdentity)User.Identity, db);
            var user = us.GetUser();
            // var user = db.AppUsers.Find(4);
            var dbpost = new Post()
            {
                Text       = post.Text,
                PostedOn   = DateTime.Now,
                User       = user,
                Convention = convention,
                Viewable   = true
            };

            db.Posts.Add(dbpost);
            db.SaveChanges();
            return(Feed(convention_id));
        }
        public ActionResult Create([Bind(Include = "Id,Date,StartTime,EndTime,Title,Text,Image")] DisplayMessage displayMessages, int convention_id, HttpPostedFileBase imageFile)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (ModelState.IsValid)
            {
                if (imageFile != null)
                {
                    displayMessages.Image = azure.GetFileName(imageFile);
                }
                convention.DisplayMessages.Add(displayMessages);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(displayMessages));
        }
        public AppUser GetApp(AppUser appUser)
        {
            us = new UserService((ClaimsIdentity)User.Identity, db);
            var user = us.GetUser();

            user.DisplayName = appUser.DisplayName;
            user.Name        = appUser.Name;
            db.SaveChanges();
            return(user);
        }
        public ActionResult Create([Bind(Include = "Id,Name,DisplayName,IsPrivate,IsMenu")] VendorType replayVendorType, int convention_id)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }

            if (ModelState.IsValid)
            {
                convention.VendorTypes.Add(replayVendorType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(replayVendorType));
        }
        public ActionResult Create([Bind(Include = "Location, ShowForEvents, ShowForGames")] GameLocation replayGameLocation, int convention_id)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (ModelState.IsValid)
            {
                convention.GameLocations.Add(replayGameLocation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(replayGameLocation));
        }
        public ActionResult RemovePermissions(int id, int perm_id)
        {
            var us   = new UserService((ClaimsIdentity)User.Identity, db);
            var user = us.GetUser();
            var perm = db.AppUserPermissions.Find(perm_id);

            if (user.isSuperAdmin || user.AppUserPermissions.Any(p => p.Convention.Id == perm.Convention.Id && p.UserRole == UserRole.Admin))
            {
                db.AppUserPermissions.Remove(perm);
                db.SaveChanges();
            }
            return(RedirectToAction("Details", new { id }));
        }
Esempio n. 12
0
        public ActionResult Create([Bind(Include = "Id,Title,Date,StartTime,EndTime,Description,ExtendedDescription,URL,Image,IsPromo,PromoImage,IsPrivate")] Event replayEvent, string categories, HttpPostedFileBase upload, HttpPostedFileBase promoUpload, int convention_id, int EventLocations)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var con = db.Conventions.Find(convention_id);

            if (con == null)
            {
                return(View(replayEvent));
            }

            if (ModelState.IsValid)
            {
                if (upload != null)
                {
                    replayEvent.Image = azure.GetFileName(upload);
                }
                if (promoUpload != null)
                {
                    replayEvent.PromoImage = azure.GetFileName(promoUpload);
                }
                replayEvent.EventLocation = con.GameLocations.Where(gl => gl.Id == EventLocations).FirstOrDefault();
                con.Events.Add(replayEvent);
                replayEvent.EventTypes = new List <EventType>();
                foreach (var id in categories.Split(','))
                {
                    if (int.TryParse(id, out int Id))
                    {
                        replayEvent.EventTypes.Add(db.EventTypes.Find(Id));
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(replayEvent));
        }
Esempio n. 13
0
        public ActionResult Create([Bind(Include = "Id,GameTitle,Overview,AtConvention,ReleaseDate,Developer,Genre,Players,Image")] Game replayGame, string gametype, string locations, HttpPostedFileBase upload, int convention_id)
        {
            var us = new UserService((ClaimsIdentity)User.Identity, db);

            if (!us.IsConventionAdmin(convention_id))
            {
                return(new HttpNotFoundResult());
            }

            var convention = db.Conventions.Find(convention_id);

            if (convention == null)
            {
                return(new HttpNotFoundResult());
            }
            if (int.TryParse(gametype, out int gametypeId))
            {
                replayGame.GameType = convention.GameTypes.Where(gt => gt.Id == gametypeId).FirstOrDefault();
            }
            ModelState.Clear();
            TryValidateModel(replayGame);
            if (ModelState.IsValid)
            {
                replayGame.Image = azure.GetFileName(upload);
                convention.Games.Add(replayGame);


                if (locations != "")
                {
                    replayGame.GameLocations = new List <GameLocation>();
                    foreach (var id in locations.Split(','))
                    {
                        if (int.TryParse(id, out int Id))
                        {
                            replayGame.GameLocations.Add(convention.GameLocations.Where
                                                             (gl => gl.Id == Id).FirstOrDefault());
                        }
                    }
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.GameTypes = convention.GameTypes.ToList();
            return(View(replayGame));
        }