コード例 #1
0
        public ActionResult ReturnCycle(CycleRequestedByUser cbru)
        {
            // var ddreq = Session["ViewRequest"];
            //var ddreq = Session["ViewRequest"];
            BikesEntities1 db = new BikesEntities1();

            //CycleRequestedByUser task = new CycleRequestedByUser();

            //var updateStatus = db.CycleRequestedByUsers.SingleOrDefault(w => w.Username == User.Identity.Name && w.RequestID == id);


            var updateStatus = db.CycleRequestedByUsers.Where(a => a.Username == User.Identity.Name).OrderByDescending(x => x.UserRequest).Take(1).Single();

            updateStatus.Status    = false;
            updateStatus.CheckDate = DateTime.Now.Date;

            db.Entry(updateStatus).State = EntityState.Modified;

            db.SaveChanges();

            ViewBag.ReturnedCycle = "Hi " + User.Identity.Name +
                                    " 😎" + " You have successfully returned the 🚲 ." +
                                    " Please click the below link to request for a new 🚲";

            ViewBag.link = "👉👉👉👉";


            return(View());
        }
コード例 #2
0
        public ActionResult DisableAccount()
        {
            // var UserActiveUntil = TodateFromTable3 + 15;
            var check1UserExits     = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Username;
            var check2StatusInTable = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Status;
            var Table3ToDate        = db.CycleRequestedByUsers.Where(a => a.Username == User.Identity.Name).Take(1).Single().ToDate.Day;
            var greater             = (Table3ToDate + 15);

            if (DateTime.Now.Day >= greater)
            {
                var updateStatus = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single();
                //var updateStatus = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Status;
                updateStatus.Status = false;
                // updateStatus.CheckDate = DateTime.Now.Date;

                db.Entry(updateStatus).State = EntityState.Modified;

                db.SaveChanges();
                ViewBag.NotifyUser = "******" + User.Identity.Name + ". You account has been disabled."
                                     + " Please contact admin for further assistance.";

                ViewBag.SendEmail = "";
            }
            else
            {
                return(Content("Hi"));
            }

            //if (check2StatusInTable.Equals(false))
            //{
            //    ViewBag.NotifyUser = "******" + User.Identity.Name + ". You account has been disabled."
            //        + " Please contact admin for further assistance.";

            //    ViewBag.SendEmail = "";
            //}
            //else
            //{
            //    return Content("Login", "Account");
            //}

            return(View());
        }
コード例 #3
0
        public ActionResult Login(DeactivationWithLoginViewModel u)
        {
            // this action is for handle post (login)
            if (ModelState.IsValid) // this is check validity
            {
                using (BikesEntities1 db = new BikesEntities1())
                {
                    var v = db.Registrations.Where(a => a.Username.Equals(u.Username) && a.Password.Equals(u.Password)).FirstOrDefault();


                    var check1UserExits     = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Username;
                    var check2StatusInTable = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Status;

                    // db.RequestCycles.Include(c => c.CycleDetail).Single(c => c.RequestID == id);


                    var Table3ToDate = db.Registrations.Include(a => a.CycleRequestedByUsers).Where(a => a.Username == User.Identity.Name).Take(1).Single().CycleRequestedByUsers.Take(1).Single().ToDate;
                    var cekDate      = db.Registrations.Include(a => a.CycleRequestedByUsers).Where(a => a.Username == User.Identity.Name).Take(1).Single().CycleRequestedByUsers.Take(1).Single().CheckDate;


                    //var check1UserExits = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Username;
                    // var check2StatusInTable = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Status;

                    if (v != null && v.Status.Equals(true))
                    {
                        FormsAuthentication.SetAuthCookie(u.Username, false);
                        ModelState.Clear();
                        return(RedirectToAction("AboutUs", "Home"));
                    }
                    else if (v != null && DateTime.Now.Date >= cekDate)
                    {
                        var updateStatus = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single();
                        //var updateStatus = db.Registrations.Where(a => a.Username == User.Identity.Name).Take(1).Single().Status;
                        updateStatus.Status = false;
                        // updateStatus.CheckDate = DateTime.Now.Date;

                        db.Entry(updateStatus).State = EntityState.Modified;

                        db.SaveChanges();
                        ViewBag.NotifyUser = "******" + User.Identity.Name + ". You account has been disabled."
                                             + " Please contact admin for further assistance.";

                        ViewBag.SendEmail = "";
                        return(View());
                        // return Content("Your account is inactive");
                    }
                }
            }
            return(View());
        }
コード例 #4
0
        public ActionResult ReturnCycle(CycleRequestedByUser cbru, int id)
        {
            // var ddreq = Session["ViewRequest"];
            //var ddreq = Session["ViewRequest"];
            BikesEntities1 db = new BikesEntities1();

            //CycleRequestedByUser task = new CycleRequestedByUser();

            var updateStatus = db.CycleRequestedByUsers.SingleOrDefault(w => w.Username == User.Identity.Name && w.RequestID == id);

            updateStatus.Status = false;

            db.Entry(updateStatus).State = EntityState.Modified;

            db.SaveChanges();
            return(View());
        }
コード例 #5
0
        public ActionResult DisplayRequestedDetails1()
        {
            var            ddreq     = Session["ViewRequest"];
            var            userddreq = Session["ViewUsername"];
            BikesEntities1 be        = new BikesEntities1();
            //using (var be = new BikesEntities())
            //{
            //var x = db.RequestCycles.Include(c => c.CycleRequestedByUsers).Single(c => c.RequestID == id);

            //foreach (var mystep in ddreq)
            //var mystep = be.RequestCycles.Where(p => p.RequestID == id).FirstOrDefault();

            //{

            // var currentDate = DateTime.Now;
            CycleRequestedByUser task = new CycleRequestedByUser();
            RequestCycle         rc   = new RequestCycle();

            //var checkDateWithDate = DateTime.Now.AddDays(7);


            task.RequestID = ((Dec_21_ASP_Bikes.Models.RequestCycle)ddreq).RequestID;
            task.CycleID   = ((Dec_21_ASP_Bikes.Models.RequestCycle)ddreq).CycleID;
            task.FromDate  = ((Dec_21_ASP_Bikes.Models.RequestCycle)ddreq).FromDate;
            task.ToDate    = ((Dec_21_ASP_Bikes.Models.RequestCycle)ddreq).ToDate;

            var ToDateWithDate = ((Dec_21_ASP_Bikes.Models.RequestCycle)ddreq).ToDate;


            task.Username  = ((Dec_21_ASP_Bikes.Models.Registration)userddreq).Username;
            task.CheckDate = ToDateWithDate.AddDays(7);

            if (task.Username != null)
            {
                task.Status = true;
                rc.Status   = true;
            }

            else
            {
                task.Status = false;
                rc.Status   = false;
            }

            be.CycleRequestedByUsers.Add(task);



            db.Entry(rc).State = EntityState.Modified;

            // db.SaveChanges();


            //}
            be.SaveChanges();
            //db.SaveChanges();

            ViewBag.InsertedDataToTable4       = "Congtaz 👍👍👍👍" + User.Identity.Name + ". Your 🚲 request was successfull";
            ViewBag.navigationToCyclesBorrowed = "🚲";



            return(View());

            //}
        }