Example #1
0
        public ActionResult ImageDelete(long?imageID, long?eventID)
        {
            Image      deletedImage = db.Images.Find(imageID);
            EventImage eventImage   = (from a in db.EventImages where a.ImageID == imageID select a).ToList()[0];

            db.EventImages.Remove(eventImage);
            db.Images.Remove(deletedImage);
            db.SaveChanges();
            return(RedirectToAction("Details", "Event", new { id = eventID }));
        }
 public void Execute(IJobExecutionContext context)
 {
     using (var db = new EventZoneEntities())
     {
         var listRank = db.EventRanks.ToList();
         foreach (var item in listRank)
         {
             item.Score = EventDatabaseHelper.Instance.CalculateEventScore(item.EventId);
         }
         db.SaveChanges();
     };
 }
Example #3
0
        public ActionResult ExternalLoginConfirmation(GoogleAccountModel model)
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user != null)
            {
                TempData["errorTittle"]  = "Bad request";
                TempData["errorMessage"] = "You are already signed in the system";
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                User newUser = UserDatabaseHelper.Instance.GetUserByUserName(model.UserName);
                if (newUser != null)
                {
                    ModelState.AddModelError("", "UserName is already exist. Please choose another.");
                    TempData["errorTitle"]   = null;
                    TempData["errorMessage"] = null;
                    return(View("ConfirmRegisterGoogle", model));
                }
                newUser               = new User();
                newUser.UserEmail     = model.Email;
                newUser.UserName      = model.UserName;
                newUser.UserPassword  = model.Password;
                newUser.UserDOB       = model.UserDOB;
                newUser.Place         = model.Place;
                newUser.UserFirstName = model.UserFirstName;
                newUser.DataJoin      = DateTime.Today;
                if (model.UserLastName != null && model.UserLastName != "")
                {
                    newUser.UserLastName = model.UserLastName;
                }
                newUser.AccountStatus = EventZoneConstants.ActiveUser; //set Active account
                newUser.Avartar       = 10032;
                newUser.UserRoles     = EventZoneConstants.User;       //set UserRole
                // insert user to Database
                db.Users.Add(newUser);
                db.SaveChanges();
                UserHelpers.SetCurrentUser(Session, newUser);
                //Send email confirm
                MailHelpers.Instance.SendMailWelcome(newUser.UserEmail, newUser.UserFirstName, newUser.UserLastName);
                TempData["errorTitle"]   = "Sucessfull SignUp";
                TempData["errorMessage"] = "Thank you for signing up in EventZone! We sent you a welcome message! Hope you have more fun and comfortable by joining with us";
                return(RedirectToAction("Index", "Home"));
            }
            TempData["errorTitle"]   = "Invald input";
            TempData["errorMessage"] = "Invalid input! Please try again";
            // If we got this far, something failed, redisplay form
            return(RedirectToAction("ExternalLoginConfirmation", "Account", model));
        }