コード例 #1
0
 public ActionResult Edit([Bind(Include = "RoomId,UserId,AC,Projector,CoffeeFilter,WaterBottles,Mic,Speaker,System,Podium,WiFi,WhiteBoard,Price,Location,CapacityOfRoom,Availability,RoomName,IsRoomBooked")] Room room)
 {
     if (ModelState.IsValid)
     {
         room.UserId          = GetId(this.User.Identity.Name);
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "UserId", "Name", room.UserId);
     return(View(room));
 }
コード例 #2
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (PromeetEntities5 dc = new PromeetEntities5())
                {
                    var user = dc.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password          = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New Password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something Invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
コード例 #3
0
        public ActionResult ForgotPassword(string EmailID)
        {
            //Verify Email Id


            //Generate Reset Password Link
            //Send Email
            string message = "";
            bool   status  = false;

            using (PromeetEntities5 dc = new PromeetEntities5())
            {
                var account = dc.Users.Where(a => a.EmailId == EmailID).FirstOrDefault();
                if (account != null)
                {
                    //Send Mail for Reset Password
                    string resetCode = Guid.NewGuid().ToString();
                    sendverificationEmail(account.EmailId, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;
                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset Password link has been sent your Email Id";
                }
                else
                {
                    message = "Account not Found";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
コード例 #4
0
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] User user)
        {
            bool   Status  = false;
            string message = "";

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

                #region //Generate activation code
                user.ActivationCode = Guid.NewGuid();
                #endregion


                #region // Password hashing
                user.Password         = Crypto.Hash(user.Password);
                user.Confirm_Password = Crypto.Hash(user.Confirm_Password);
                #endregion
                user.IsEmailVerified = false;

                #region //Save data to database
                using (PromeetEntities5 db = new PromeetEntities5())
                {
                    db.Users.Add(user);
                    db.SaveChanges();

                    //Send details to user via email
                    sendverificationEmail(user.EmailId, user.ActivationCode.ToString());
                    message = "Registration successfully completed. Check your email to verify the account. " + user.EmailId;
                    Status  = true;
                }
                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;

            return(View(user));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "RoomId,UserId,Payment_Money,Location,Date_Time,Duration")] Booking booking, int roomid)
        {
            string message = "";
            bool   Status  = false;

            booking.RoomId = roomid;
            booking.UserId = GetId(this.User.Identity.Name);
            if (ModelState.IsValid)
            {
                db.Bookings.Add(booking);
                db.SaveChanges();

                sendconfirmationEmail(this.User.Identity.Name);
                message = "Booking Successful. Check your email to confirm booking. " + this.User.Identity.Name;
                Status  = true;
            }
            ViewBag.Message = message;
            ViewBag.Status  = Status;

            ViewBag.RoomId = new SelectList(db.Rooms, "RoomId", "RoomId", booking.RoomId);

            return(View(booking));
        }
コード例 #6
0
        public ActionResult AddRoom([Bind(Exclude = "IsRoomBooked")] Room room)
        {
            bool   Status  = false;
            string message = "";

            //Model Validation
            if (ModelState.IsValid)
            {
                room.UserId = GetId(this.User.Identity.Name);

                #region //RoomName already Exists

                var isExist = IsRoomExist(room.RoomName, room.UserId);
                if (isExist)
                {
                    ModelState.AddModelError("RoomExist", "Room Already Added");
                    return(View(room));
                }
                #endregion

                #region //Save data to database
                using (PromeetEntities5 db = new PromeetEntities5())
                {
                    db.Rooms.Add(room);
                    db.SaveChanges();

                    message = "Room added successfully ";
                    Status  = true;
                }
                return(RedirectToAction("Index", "Rooms"));

                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;

            return(View());
        }
コード例 #7
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (PromeetEntities5 db = new PromeetEntities5())
            {
                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());
        }