Exemple #1
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                customer.Active = true;
            }
            db.Customers.Add(customer);
            db.SaveChanges();

            return(RedirectToAction("Index"));


            {
                return(View(customer));
            }
        }
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
                {
                    var users = db.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (User != null)
                    {
                        users.Password          = Crypto.Hash(model.NewPassword);
                        users.ResetPasswordCode = "";
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        message = "Your new password has been updated succesfully!";
                    }
                }
            }
            else
            {
                message = "Invalid request";
            }
            ViewBag.Message = message;

            return(View(model));
        }
        public ActionResult ForgotPassword(string EmailID)
        {
            string message = "";
            bool   status  = false;

            using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
            {
                var acc = db.Users.Where(a => a.EmailID == EmailID).FirstOrDefault();
                if (acc != null)
                {
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLink(acc.EmailID, resetCode, "ResetPassword");
                    acc.ResetPasswordCode = resetCode;
                    db.Configuration.ValidateOnSaveEnabled = false;
                    db.SaveChanges();
                    message = "The reset password link has been sent to the email listed on your account!";
                }
                else
                {
                    message = "Im affraid the account you've requested has not been found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Exemple #4
0
        public JsonResult SaveEvent(Events e)
        {
            var status = false;
            var r      = db.Events.ToList();

            using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
            {
                if (e.EventID > 0)
                {
                    //Update event
                    var v = db.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsFullDay   = e.IsFullDay;
                        v.ThemeColor  = e.ThemeColor;
                    }
                }
                else
                {
                    db.Events.Add(e);
                }
                db.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
 public ActionResult Create(BookingsModel.Staff staff)
 {
     try
     {
         if (ModelState.IsValid)            //if model state is active/.
         {
             staff.Active = true;           //I have set active so what sstaff are created its shows in the view .
         }
         db.Staffs.Add(staff);              //create the bu in the database
         db.SaveChanges();                  //save the changes.
         return(RedirectToAction("Index")); //retur nto index
     }
     catch
     {
         return(View(staff));
     }
 }
Exemple #6
0
 public ActionResult Create(BookingsModel.ServiceType type_)
 {
     try
     {
         if (ModelState.IsValid) //if model state is active/.
         {
             db.ServiceTypes.Add(type_);
         }
         db.SaveChanges();
         return(RedirectToAction("Index")); //retur nto index
     }
     catch
     {
         return(View(type_));
     }
 }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Users users)
        {
            bool   Status  = false;
            String Message = "";

            if (ModelState.IsValid)
            {
                #region Does the Email exist?
                var exists = EmailExists(users.EmailID);
                if (exists)
                {
                    ModelState.AddModelError("EmailExists", "Email already exists");
                    return(View(User));
                }
                #endregion

                #region Generate Activation Code
                users.ActivationCode = Guid.NewGuid();
                #endregion

                #region Password Hashing
                users.Password        = Crypto.Hash(users.Password);
                users.ConfirmPassword = Crypto.Hash(users.ConfirmPassword);
                users.IsEmailVerified = false;
                #endregion

                #region Save to db
                using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
                {
                    db.Users.Add(users);
                    db.SaveChanges();

                    SendVerificationLink(users.EmailID, users.ActivationCode.ToString());
                    Message = "Registration sucessfully done. Account activation link " +
                              "has been send to your email id " + users.EmailID;
                    Status = true;
                }
            }
            else
            {
                Message = "Invalid Request";
            }
            ViewBag.Message = Message;
            ViewBag.Status  = Status;

            return(View(users));
        }
Exemple #8
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
            {
                var v = db.Events.Where(a => a.EventID == eventID).FirstOrDefault();
                if (v != null)
                {
                    db.Events.Remove(v);
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (BookingsModel.ModelBookings db = new BookingsModel.ModelBookings())
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                var v = db.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    db.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.MEssage = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }