internal DateTime GetLastDate(uint id) { var res = DbConn.GetAllBorrowsWithThisItem(id); var lastDate = DateTime.Now; if (res[0].ToString() == "Success") { var paraList = (List <object>)res[1]; var list = FillBorrowList(paraList); lastDate = Convert.ToDateTime(list[0].Availability); foreach (var borrow in list) { var listDate = Convert.ToDateTime(borrow.Availability); if (listDate > lastDate) { lastDate = listDate; } } } return(lastDate); }
public void OnGet() { var parameter = Request.Query["id"].Count > 0 ? Request.Query["id"][0] : string.Empty; if (uint.TryParse(parameter, out uint id)) { Item = MainMethods.GetItem(id); if (Item.Name != null) { var res = DbConn.GetAllBorrowsWithThisItem(id); if (res[0].ToString() == "Success") { var paraList = (List <object>)res[1]; BorrowList = MainMethods.FillBorrowList(paraList); } } else { Response.Redirect("/Item/Index?status=6"); } } else { Response.Redirect("/Item/Index?status=3"); } }
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"); } }