示例#1
0
        public ActionResult Create(EventComment eventComment)
        {
            if (ModelState.IsValid)
            {
                eventComment.CommentTime = DateTime.Now;
                db.EventComments.Add(eventComment);
                db.SaveChanges();
                var evt = db.Events.Find(eventComment.EventID);
                if (evt.HostID != User.Identity.GetUserId())
                {
                    var    subject = $"Alert for {evt.Location}";
                    string Username;
                    if (User.IsInRole("GM"))
                    {
                        Username = db.GMs.Find(User.Identity.GetUserId()).Username;
                    }
                    else
                    {
                        Username = db.Players.Find(User.Identity.GetUserId()).Username;
                    }
                    var messageBody = $"{Username} commented : \n {eventComment.Comment}";
                    MessageSender.SendEmail(subject, messageBody, evt.GM.Email);
                }
                return(RedirectToAction("Details", "Events", new { id = eventComment.EventID }));
            }

            ViewBag.Event = db.Events.Find(eventComment.EventID);

            return(View(eventComment));
        }
示例#2
0
        public ActionResult Create([Bind(Include = "GMID,Username,FirstName,LastName,Email,PreferredMedium,Bio,AvatarFilename")] GM gM)
        {
            if (ModelState.IsValid)
            {
                db.GMs.Add(gM);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gM));
        }
        public ActionResult Create([Bind(Include = "PlayerID,Username,FirstName,LastName,Email,PreferredMedium,Bio,PreferredType,AvatarFilename")] Player player)
        {
            if (ModelState.IsValid)
            {
                db.Players.Add(player);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(player));
        }
        public ActionResult Create(Event @event)
        {
            if (ModelState.IsValid)
            {
                db.Events.Add(@event);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.HostID = new SelectList(db.GMs, "GMID", "Username", @event.HostID);
            return(View(@event));
        }
        public ActionResult Create([Bind(Include = "RatingID,PlayerID,GMID,Comment,Rating,RatingTime")] PlayerRating playerRating)
        {
            if (ModelState.IsValid)
            {
                db.PlayerRatings.Add(playerRating);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GMID     = new SelectList(db.GMs, "GMID", "Username", playerRating.GMID);
            ViewBag.PlayerID = new SelectList(db.Players, "PlayerID", "Username", playerRating.PlayerID);
            return(View(playerRating));
        }
示例#6
0
        public ActionResult Create(GMRating gMRating)
        {
            if (ModelState.IsValid)
            {
                gMRating.RatingTime = DateTime.Now;
                db.GMRatings.Add(gMRating);
                db.SaveChanges();
                return(RedirectToAction("Details", "GMs", new { id = gMRating.GMID }));
            }

            ViewBag.GM = db.GMs.Find(gMRating.GMID);
            return(View(gMRating));
        }
        public ActionResult Create([Bind(Include = "SignupID,PlayerID,EventID,IsApproved,CommentGM,CommentPlayer")] PlayerSignup playerSignup)
        {
            if (ModelState.IsValid)
            {
                db.PlayerSignups.Add(playerSignup);
                db.SaveChanges();
                var evt = db.Events.Find(playerSignup.EventID);
                if (evt.HostID != User.Identity.GetUserId())
                {
                    var    subject  = $"Alert for {evt.Location}";
                    string Username = db.Players.Find(User.Identity.GetUserId()).Username;

                    var messageBody = $"{Username} submitted a sign-up attempt : \n {playerSignup.CommentPlayer}";
                    MessageSender.SendEmail(subject, messageBody, evt.GM.Email);
                }
                return(RedirectToAction("Details", "Events", new { id = playerSignup.EventID }));
            }

            ViewBag.Event = db.Events.Find(playerSignup.EventID);
            return(View(playerSignup));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Username, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    using (var db = new RPGGroupFinderEntities())
                    {
                        if (model.IsGM)
                        {
                            var gm = new GM
                            {
                                Bio             = model.Bio,
                                Email           = model.Email,
                                FirstName       = model.FirstName,
                                LastName        = model.LastName,
                                PreferredMedium = model.PreferredMedium,
                                Username        = model.Username,
                                GMID            = user.Id
                            };
                            db.GMs.Add(gm);

                            UserManager.AddToRole(user.Id, "GM");
                        }
                        else
                        {
                            var player = new Player
                            {
                                Bio             = model.Bio,
                                Email           = model.Email,
                                FirstName       = model.FirstName,
                                LastName        = model.LastName,
                                PreferredMedium = model.PreferredMedium,
                                Username        = model.Username,
                                PlayerID        = user.Id,
                                PreferredType   = model.PreferredType
                            };
                            db.Players.Add(player);

                            UserManager.AddToRole(user.Id, "Player");
                        }

                        db.SaveChanges();
                    }

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }