Ejemplo n.º 1
0
 public ActionResult Index1(CycleRequestedByUser crbu)
 {
     if (ModelState.IsValid)
     {
         db.CycleRequestedByUsers.Add(crbu);
         //db.Entry(crbu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("DisplayImage", "Image"));
     }
     //ViewBag.dropdownlist = new SelectList(db.CycleDetails, "CycleID", "CycleID");
     return(View(crbu));
 }
Ejemplo n.º 2
0
        public ActionResult DD()
        {
            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();

            //{
            CycleRequestedByUser task = new CycleRequestedByUser();

            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;
            task.Username  = ((Dec_21_ASP_Bikes.Models.Registration)userddreq).Username;

            be.CycleRequestedByUsers.Add(task);
            //}
            be.SaveChanges();
            return(View());

            //}
        }
        public ActionResult RequestCycleAdminInsertion(RequestCycle rc)
        {
            if (ModelState.IsValid)
            {
                //if (rc.ToDate != null)
                //{
                //    rc.Status = true;
                //}

                //else
                //{
                //    rc.Status = false;
                //}
                //var cycleId = db.CycleRequestedByUsers.Where(a => a.Username == User.Identity.Name).Select(a=>a.CycleID);


                if (rc.CycleID.Equals(null))
                {
                    ViewBag.CycleIDError = "Sorry. Currently there are no Cycles available to raise a request.";
                }
                else
                {
                    db.RequestCycles.Add(rc);
                    db.SaveChanges();



                    return(RedirectToAction("CycleList", "CycleDetailsList"));
                }// return RedirectToAction("RequestCycleAdminInsertion", "InsertRequestForCycle");
            }
            //ViewBag.dropdownlist = new SelectList(db.CycleDetails, "CycleID", "CycleID");
            return(View(rc));
        }
Ejemplo n.º 4
0
        public ActionResult AddImage(CycleDetail model, HttpPostedFileBase image1)
        {
            //creating an object of the context class to save the file into database table.
            var db = new BikesEntities1();

            //check if the image1 (id or name) is not equal to null
            if (image1 != null)
            {
                //convert your image into binary format;

                model.CycleImage = new byte[image1.ContentLength];

                //inputstream is used to convert the actual data to binary format
                image1.InputStream.Read(model.CycleImage, 0, image1.ContentLength);
            }

            //save model into datacontext
            db.CycleDetails.Add(model);
            db.SaveChanges();
            ModelState.Clear();
            ViewBag.InsertedImageDetails = "Cycle Details were inserted successfully";


            return(View(model));
        }
        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());
        }
Ejemplo n.º 6
0
        public ActionResult RequestName(CycleRequestedByUser rbu)
        {
            // try
            //{
            BikesEntities1 db = new BikesEntities1();

            // List<RequestCycle> rc = db.rc.ToList();

            //////int rid = rbu.RequestID;
            // int cid = rbu.CycleID;
            // DateTime fd = rbu.FromDate;
            //  DateTime td = rbu.ToDate;

            // CycleRequestedByUser crbu = new CycleRequestedByUser();
            // crbu.RequestID = rbu.RequestID;
            //crbu.CycleID = rbu.CycleID;
            //crbu.FromDate = (DateTime)rbu.FromDate;
            //  crbu.ToDate = (DateTime)rbu.ToDate;

            //select and insert statement

            db.CycleRequestedByUsers.Add(rbu);
            db.SaveChanges();
            //  }
            //catch (Exception ex)
            //  {
            //throw ex;


            //int RequestedCycleFromViewID = crbu.RequestID;

            return(View(rbu));
        }
Ejemplo n.º 7
0
        //For Delete method
        public ActionResult DeleteSelected(string[] ids)
        {
            //Delete Selected
            int[] id = null;
            if (ids != null)
            {
                id = new int[ids.Length];
                int j = 0;
                foreach (string i in ids)
                {
                    int.TryParse(i, out id[j++]);
                }
            }

            if (id != null && id.Length > 0)
            {
                List <CycleDetail> allSelected = new List <CycleDetail>();
                using (BikesEntities1 db = new BikesEntities1())
                {
                    allSelected = db.CycleDetails.Where(a => id.Contains(a.CycleID)).ToList();
                    foreach (var i in allSelected)
                    {
                        db.CycleDetails.Remove(i);
                    }
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("DeleteList"));
        }
Ejemplo n.º 8
0
 public ActionResult NavigateToRequestPage(CycleRequestedByUser crbu)
 {
     if (ModelState.IsValid)
     {
         db.CycleRequestedByUsers.Add(crbu);
         db.SaveChanges();
         return(RedirectToAction("DisplayImage", "Image"));
     }
     //ViewBag.dropdownlist = new SelectList(db.CycleDetails, "CycleID", "CycleID");
     return(View(crbu));
 }
Ejemplo n.º 9
0
 public ActionResult New(RequestCycle reg)
 {
     if (ModelState.IsValid)
     {
         BikesEntities1 db = new BikesEntities1();
         db.RequestCycles.Add(reg);
         db.SaveChanges();
         ModelState.Clear();
         reg = null;
         ViewBag.SuccessRegistration = "Registration was successfull";
     }
     return(View());
 }
Ejemplo n.º 10
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());
        }
        public ActionResult RequestCycleAdminInsertion(RequestCycle rc)
        {
            if (ModelState.IsValid)
            {
                db.RequestCycles.Add(rc);
                db.SaveChanges();



                return(RedirectToAction("RequestCycleAdminInsertion", "TechnicalSupport"));
            }
            //ViewBag.dropdownlist = new SelectList(db.CycleDetails, "CycleID", "CycleID");
            return(View(rc));
        }
Ejemplo n.º 12
0
 public ActionResult RegisterCycle(CycleRequestedByUser U)
 {
     if (ModelState.IsValid)
     {
         using (BikesEntities1 db = new BikesEntities1())
         {
             //you should check duplicate registration here
             db.CycleRequestedByUsers.Add(U);
             db.SaveChanges();
             ModelState.Clear();
             U = null;
             ViewBag.registrationSuccess = "Registration was Successfull. Welcome ";
             // return RedirectToAction("Index", "Home");
         }
     }
     return(View(U));
 }
Ejemplo n.º 13
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());
        }
Ejemplo n.º 14
0
        public ActionResult Register(Registration U)
        {
            if (ModelState.IsValid)
            {
                using (BikesEntities1 db = new BikesEntities1())
                {
                    //you should check duplicate registration here

                    db.Registrations.Add(U);

                    db.SaveChanges();

                    ModelState.Clear();
                    U = null;


                    ViewBag.SuccessMessage = "Congratzzzz 👍👍👍👍.  Your registration was successfull";
                    ViewBag.link           = "👉👉👉👉";
                }
            }
            return(View(U));
        }
Ejemplo n.º 15
0
        public ActionResult Index3(RequestCycle rbu)
        {
            BikesEntities1      db = new BikesEntities1();
            List <RequestCycle> rc = db.RequestCycles.ToList();

            int      rid = rbu.RequestID;
            int      cid = rbu.CycleID;
            DateTime fd  = rbu.FromDate;
            DateTime td  = rbu.ToDate;

            CycleRequestedByUser crbu = new CycleRequestedByUser();

            crbu.RequestID = rbu.RequestID;
            crbu.CycleID   = rbu.CycleID;
            crbu.FromDate  = (DateTime)rbu.FromDate;
            crbu.ToDate    = (DateTime)rbu.ToDate;

            //select and insert statement

            db.CycleRequestedByUsers.Add(crbu);
            db.SaveChanges();

            return(View());
        }
Ejemplo n.º 16
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());

            //}
        }