Exemplo n.º 1
0
        public void OnGet()
        {
            var resList   = DbConn.GetAllBorrows();
            var parameter = Convert.ToInt32(Request.Query["status"]);

            StatusMessage = MainMethods.StatusHandler(parameter);

            if (resList[0].ToString() == "Success")
            {
                var paraList = (List <object>)resList[1];

                if (paraList.Count > 0)
                {
                    BorrowList = MainMethods.FillBorrowList(paraList);

                    //Wenn alles bei den Verleihen geklappt hat werden nun die Items dazu aus der Datenbank geholt
                    resList = DbConn.GetAllItems();

                    if (resList[0].ToString() == "Success")
                    {
                        paraList = (List <object>)resList[1];

                        if (paraList.Count > 0)
                        {
                            ItemList = MainMethods.FillItemList(paraList);
                        }
                    }
                }
            }
            else
            {
                StatusMessage = "Beim Laden der Daten aus der Datenbank geschah ein Fehler!";
            }
        }
Exemplo n.º 2
0
        public void OnGet()
        {
            if (MainMethods.IsUserCreator(User.Identity.Name) == "J")
            {
                var resList   = DbConn.GetAllItems();
                var parameter = Convert.ToInt32(Request.Query["status"]);

                StatusMessage = MainMethods.StatusHandler(parameter);

                if (resList[0].ToString() == "Success")
                {
                    var paraList = (List <object>)resList[1];

                    if (paraList.Count > 0)
                    {
                        ItemList = MainMethods.FillItemList(paraList);

                        foreach (var item in ItemList)
                        {
                            var selectItem = new SelectListItem(item.Id + ". " + item.Description, item.Id.ToString());
                            Items.Add(selectItem);
                        }
                    }

                    if (Request.Query["id"].Count > 0)
                    {
                        var paraId = Request.Query["id"][0];

                        foreach (var item in Items)
                        {
                            if (item.Value == paraId)
                            {
                                item.Selected = true;
                            }
                        }

                        var res = DbConn.GetAllBorrowsWithThisItem(Convert.ToUInt32(paraId));

                        if (res[0].ToString() == "Success" && StatusMessage.Length > 0)
                        {
                            var lastDate = MainMethods.GetLastDate(Convert.ToUInt32(paraId));

                            StatusMessage += $" Item ist ab dem {lastDate:dd.MM.yyyy} wieder komplett verfügbar!";
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Borrow/Index?status=3");
                }
            }
            else
            {
                Response.Redirect("/Borrow/Index?status=2");
            }
        }
Exemplo n.º 3
0
        public void OnGet()
        {
            if(Request.Query["search"].Count > 0)
            {
                SearchString = Request.Query["search"][0];
                OnlyAvailable = Convert.ToBoolean(Request.Query["available"][0]);
                var resList = DbConn.GetAllSearchedItems(SearchString);

                if(resList[0].ToString() == "Success")
                {
                    var paraList = (List<object>)resList[1];
                    ItemList = new List<ItemModel>();

                    if(OnlyAvailable == true)
                    {
                        var list = MainMethods.FillItemList(paraList);
                        foreach (var item in list)
                        {
                            if (!IsItemBorrowed(item.Id))
                            {
                                ItemList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        ItemList = MainMethods.FillItemList(paraList);
                    }
                }
            }
            else
            {
                var resList = DbConn.GetAllItems();
                var parameter = Convert.ToInt32(Request.Query["status"]);

                StatusMessage = MainMethods.StatusHandler(parameter);

                if (resList[0].ToString() == "Success")
                {
                    var paraList = (List<object>)resList[1];

                    if (paraList.Count > 0)
                    {
                        ItemList = MainMethods.FillItemList(paraList);
                    }
                }
                else
                {
                    StatusMessage = "Beim Laden der Daten aus der Datenbank geschah ein Fehler!";
                }
            }

            
        }
Exemplo n.º 4
0
        public void OnGet()
        {
            if (MainMethods.IsUserCreator(User.Identity.Name) == "J")
            {
                var parameter = Request.Query["id"].Count > 0 ? Request.Query["id"][0] : string.Empty;

                if (uint.TryParse(parameter, out uint id))
                {
                    Borrow = MainMethods.GetBorrow(id);
                    Item   = MainMethods.GetItem(Borrow.ItemId);

                    BorrowDate   = Convert.ToDateTime(Borrow.BorrowDate).ToString("yyyy-MM-dd");
                    Availability = Convert.ToDateTime(Borrow.Availability).ToString("yyyy-MM-dd");

                    var res = DbConn.GetAllItems();

                    if (res[0].ToString() == "Success")
                    {
                        var paraList = (List <object>)res[1];
                        ItemList = MainMethods.FillItemList(paraList);
                        foreach (var item in ItemList)
                        {
                            var selectItem = new SelectListItem(item.Id + ". " + item.Description, item.Id.ToString());
                            Items.Add(selectItem);
                        }

                        if (Request.Query["itemId"].Count > 0)
                        {
                            var paraId = Request.Query["itemId"][0];

                            foreach (var item in Items)
                            {
                                if (item.Value == paraId)
                                {
                                    item.Selected = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Borrow/Index?status=3");
                }
            }
            else
            {
                Response.Redirect("/Borrow/Index?status=2");
            }
        }
Exemplo n.º 5
0
        private void FillItemList()
        {
            var res = DbConn.GetAllItems();

            if (res[0].ToString() == "Success")
            {
                var paraList = (List <object>)res[1];

                ItemList = MainMethods.FillItemList(paraList);
            }
            else
            {
                StatusMessage = "Fehler in der Datenbank";
            }
        }