public ActionResult ResetPassword(int id = 0)
        {
            //Verify the reset password link
            //Find account associated with this link
            //redirect to reset password page
            //if (string.IsNullOrWhiteSpace(id))
            //{
            //    return HttpNotFound();
            //}

            using (SpartanFireDBEntities1 dc = new SpartanFireDBEntities1())
            {
                //var user = dc.Users.Where(a => a.UserEmail == id).FirstOrDefault();
                //if (user != null)
                //{
                User model = new User();
                model.UserID = id;
                return(View(model));
                //}
                //else
                //{
                //    return HttpNotFound();
                //}
            }
        }
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (SpartanFireDBEntities1 dc = new SpartanFireDBEntities1())
            {
                var account = dc.Users.Where(a => a.UserEmail == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send email for reset password
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.UserEmail, resetCode, "ResetPassword");
                    //account.ResetPasswordCode = resetCode;
                    //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property
                    //in our model class in part 1
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset password link has been sent to your email id.";
                }
                else
                {
                    message = "Account not found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
 public JsonResult GetEvents()
 {
     using (SpartanFireDBEntities1 dc = new SpartanFireDBEntities1())
     {
         var events = dc.Events.ToList();
         return(new JsonResult {
             Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Exemple #4
0
        public ActionResult Authorise(Snow_System.Models.mvcUserModel userModel)
        {
            using (SpartanFireDBEntities1 db = new SpartanFireDBEntities1())
            {
                var userDetails = db.Users.Where(x => x.UserEmail == userModel.UserEmail && x.UserPassword == userModel.UserPassword).FirstOrDefault();
                if (userDetails == null)
                {
                    userModel.LoginErrorMessage = "Wrong username or password.";
                    return(View("Index", userModel));
                }

                else
                {
                    Session["UserID"]     = userDetails.UserID;
                    Session["UserEmail"]  = userDetails.UserEmail;
                    Session["UserRoleID"] = userDetails.UserRoleID;
                    int temp = 0;
                    if ((int)Session["UserRoleID"] == 1)
                    {
                        temp = db.Clients.Where(c => c.UserID == userDetails.UserID).Select(c => c.ClientID).FirstOrDefault();
                        Session["ClientID"] = temp;
                    }
                    Globals.Username = userModel.UserEmail;
                    Globals.Password = userModel.UserPassword;
                    if (userDetails.UserRoleID == 1)
                    {
                        Location l = db.Locations.Where(m => m.ClientID == temp).FirstOrDefault();
                        if (l == null)
                        {
                            Session["ActionID"] = 1;
                            TempData["Title"]   = "Please add a location before you start";
                            return(RedirectToAction("AddOrEdit", "Location", new { cid = temp }));
                        }
                        else
                        {
                            return(RedirectToAction("Home", "Home"));
                        }
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                }
            }
        }
        public ActionResult ResetPassword(User model)
        {
            try
            {
                var message = "";
                //if (ModelState.IsValid)
                //{

                SpartanFireDBEntities1 unew = new SpartanFireDBEntities1();
                //int num = model.UserID;
                //where model.password = u .password

                var cc = unew.Users.Where(a => a.UserEmail == model.UserEmail).FirstOrDefault();
                cc.UserPassword = (model.UserPassword);
                //unew.Users.Find(25).UserPassword = model.UserPassword;
                //user.UserEmail = "";
                //dc.Configuration.ValidateOnSaveEnabled = false;
                unew.SaveChanges();
                message = "New password updated successfully";


                //}
                //else
                //{
                //    message = "Something invalid";
                //}
                ViewBag.Message = message;
                return(View(model));
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
        // GET: TreeView
        public ActionResult Index()
        {
            List <TreeViewNode>    nodes    = new List <TreeViewNode>();
            SpartanFireDBEntities1 entities = new SpartanFireDBEntities1();

            //Loop and add the Parent Nodes.
            //foreach (Vehicle type in entities.Vehicles)
            //{
            //    nodes.Add(new TreeViewNode { id = type.VehicleTypeID.ToString(), parent = "#", text = type.Description });
            //}

            ////Loop and add the Child Nodes.
            //foreach (VehicleType subType in entities.VehicleTypes)
            //{
            //    nodes.Add(new TreeViewNode { id = subType.VehicleTypeID.ToString() + "-" + subType.VehicleTypeID.ToString(), parent = subType.VehicleTypeID.ToString(), text = subType.Description });
            //}


            //Loop and add the Parent Nodes.
            foreach (VehicleType type in entities.VehicleTypes)
            {
                nodes.Add(new TreeViewNode {
                    id = type.VehicleTypeID.ToString(), parent = "#", text = type.Description
                });
            }

            //Loop and add the Child Nodes.
            foreach (Vehicle subType in entities.Vehicles)
            {
                nodes.Add(new TreeViewNode {
                    id = subType.VehicleTypeID.ToString() + "-" + subType.VehicleTypeID.ToString(), parent = subType.VehicleTypeID.ToString(), text = subType.Description
                });
            }

            //Serialize to JSON string.
            ViewBag.Json = (new JavaScriptSerializer()).Serialize(nodes);
            return(View());
        }