Exemple #1
0
        //[AllowAnonymous]
        public ActionResult Reserve()
        {
            var myLoanDataUtil       = new LoanDataUtil();
            var myloanedComponents   = new Components();
            var myreservedComponents = new Components();

            if (Session["User"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            // Tjekker om der er indtastet en s�gning, hvis ja, hentes en komponentliste med de indtastede tags
            if (!String.IsNullOrEmpty(Session["User"].ToString()))
            {
                var studieNr = Session["User"].ToString();

                foreach (var component in myLoanDataUtil.GetLoanedComponentFromStudentId(studieNr))
                {
                    myloanedComponents._components.Add(component);
                }

                foreach (var component in myLoanDataUtil.GetReservedComponentFromStudentId(studieNr))
                {
                    myreservedComponents._components.Add(component);
                }

                var SortedReserveList = myreservedComponents._components.OrderBy(c => c.ComponentName).ToList();
                var SortedLoanList    = myloanedComponents._components.OrderBy(c => c.ComponentName).ToList();
                var SortedReserveLoanInformationList = new List <string>();
                var SortedLoanedLoanInformationList  = new List <string>();


                ViewData["ReservedComponents"] = SortedReserveList;
                ViewData["LoanedComponents"]   = SortedLoanList;

                foreach (var component in SortedReserveList)
                {
                    SortedReserveLoanInformationList.Add(myLoanDataUtil.GetLoanInformation(component).ReservationDate.Value.Value.ToShortDateString());
                }
                foreach (var component in SortedLoanList)
                {
                    SortedLoanedLoanInformationList.Add(myLoanDataUtil.GetLoanInformation(component).ReturnDate.Value.Value.ToShortDateString());
                }

                ViewData["ReservedLoanInformation"] = SortedReserveLoanInformationList;
                ViewData["LoanedLoanInformation"]   = SortedLoanedLoanInformationList;
            }

            return(View());
        }
        public ActionResult Remove(Component component)
        {
            var loanDataUtil = new LoanDataUtil();
            var loanInfo     = loanDataUtil.GetLoanInformation(component);

            if (Session["User"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (Session["User"].ToString() == loanInfo.ReservationID)
            {
                loanDataUtil.RemoveReservation(component.ComponentID);
            }

            return(RedirectToAction("Reserve", "Account"));
        }