public ActionResult Create([Bind(Include = "")] Competition competition)
        {
            string fileDir = "~/Content/Upload/";

            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var ext      = Path.GetExtension(file.FileName);
                    var fileName = competition.CompetitionName + "" + ext;
                    var path     = Path.Combine(Server.MapPath("~/Content/Upload/"), fileName);
                    fileDir += fileName;
                    file.SaveAs(path);
                }
            }
            competition.competitionpicture = fileDir;
            competition.status             = 1;
            db.Competition.Add(competition);
            db.SaveChanges();

            var client = new SmtpClient("smtp.mailtrap.io", 2525)
            {
                Credentials = new NetworkCredential("52989bbb90ab6d", "90b65713e2b630"),
                EnableSsl   = true
            };
            IEnumerable <Gamer> allGamer  = db.Gamers.ToList();
            Organizer           organizer = AuthUser.getOrganizerUser();

            foreach (var data in allGamer)
            {
                client.Send(organizer.Organizeremail, data.Email, " New Compition ", "Your prefered game compition is created ");
            }

            return(RedirectToAction("Index", "Competition", new { id = competition.Organizerid }));


            ViewBag.Organizerid = new SelectList(db.Organizer, "Organizerid", "organizeremail", competition.Organizerid);
            return(View("~/Views/Home/Competitonorganization.cshtml", competition));
        }
Exemple #2
0
        public ActionResult DashBoard()
        {
            System.Diagnostics.Debug.WriteLine(AuthUser.isAdminLogIn());
            if (AuthUser.isAdminLogIn())
            {
                HttpCookie myCookie = AuthUser.getUserType();

                if (myCookie.Value.Contains("gamer"))
                {
                    Gamer gm = AuthUser.getGamerUser();
                    return(RedirectToAction("ProfileView", "Home", new { id = gm.GamerId }));
                }
                if (myCookie.Value.Contains("organizer"))
                {
                    Organizer or = AuthUser.getOrganizerUser();
                    return(RedirectToAction("Organizerprofileview", "Home", new { id = or.Organizerid }));
                }
            }
            else
            {
                return(RedirectToAction("Logout"));
            }
            return(null);
        }
Exemple #3
0
        public ActionResult GiveReviewForm()
        {
            string type   = Request["type"];
            string email  = Request["email"];
            string rating = Request["rating"];

            if (email == null || email == "")
            {
                return(Content("Please Give Email"));
            }

            HttpCookie myCookie = AuthUser.getUserType();

            if (myCookie.Value.Contains("gamer"))
            {
                Gamer gm = AuthUser.getGamerUser();
                if (type.Contains("gamer"))
                {
                    return(Content("You Can not review Gammer"));
                }
                else
                {
                    Organizer gn = db.Organizer.Where(u => u.Organizeremail == email).SingleOrDefault();
                    if (gn == null)
                    {
                        return(Content("Please Give Correct User email"));
                    }
                    else
                    {
                        gn.rating       += Convert.ToInt32(rating);
                        gn.reviewmember += 1;
                        db.SaveChanges();
                    }
                }
                return(RedirectToAction("ProfileView", "Home", new { id = gm.GamerId }));
            }
            if (myCookie.Value.Contains("organizer"))
            {
                Organizer or = AuthUser.getOrganizerUser();

                if (type.Contains("organizer"))
                {
                    return(Content("You Can not review Organizer"));
                }
                else
                {
                    Gamer gn = db.Gamers.Where(u => u.Email == email).SingleOrDefault();
                    if (gn == null)
                    {
                        return(Content("Please Give Correct User email"));
                    }
                    else
                    {
                        gn.rating       += Convert.ToInt32(rating);
                        gn.reviewmember += 1;
                        db.SaveChanges();
                    }
                }
                return(RedirectToAction("Organizerprofileview", "Home", new { id = or.Organizerid }));
            }

            return(Content("Thank you giving rating email " + email));
        }