public ActionResult Edit(int id, BookingDetail bookingDetail)
        {
            try
            {
                using (UserRegistrationEntities6 dBModel = new UserRegistrationEntities6())
                {
                    var isExist = IsTimeExist(bookingDetail.TimeForBooking, bookingDetail.StylistName, bookingDetail.DateForBooking);
                    if (isExist)
                    {
                        ModelState.AddModelError("Time exist", "Time already exist");
                        return(View(bookingDetail));
                    }
                    else
                    {
                        dBModel.BookingDetails.Add(bookingDetail);
                        dBModel.SaveChanges();
                    }
                    dBModel.Entry(bookingDetail).State = EntityState.Modified;
                    dBModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (ModelState.IsValid)
            {
                #region //Email is already Exist
                var isExist = IsEmailExist(user.EmailID);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email already exist");
                    return(View(user));
                }
                #endregion

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

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

                #region Save to Database
                using (UserRegistrationEntities6 dc = new UserRegistrationEntities6())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(user.EmailID, user.ActivationCode.ToString());
                    message = "Registration successfully done. Account activation link " +
                              " has been sent to your email id:" + user.EmailID;
                    Status = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
        public ActionResult Delete(int id, BookingDetail bookingDetail)
        {
            try
            {
                using (UserRegistrationEntities6 dBModel = new UserRegistrationEntities6())
                {
                    BookingDetail booking = dBModel.BookingDetails.Where(x => x.UserID == id).FirstOrDefault();
                    dBModel.BookingDetails.Remove(bookingDetail);
                    dBModel.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (UserRegistrationEntities6 dc = new UserRegistrationEntities6())
            {
                dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid
                                                                // Confirm password does not match issue on save changes
                var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                    Status          = false;
                }
            }
            ViewBag.Status = Status;
            return(View());
        }