Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("InventoryNumber,DatePurchased,DateWarrantyExpires,IsLoanable,ModelID,StateID,LocationID,ID")] Asset Asset)
        {
            if (LoggedIn == false)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (CurrentUser.Role.AssetsEdit)
            {
                if (ModelState.IsValid)
                {
                    LoanedAsset LA = DAL.GetLoanedAssetAndUserByAssetID((int)id);
                    if (LA != null)
                    {
                        ViewBag.LoanedAsset = LA;
                        Asset.IsLoanable    = true;
                    }
                    DAL.UpdateAsset(Asset);
                    return(View(DAL.GetAssetByID((int)id)));
                }

                return(View());
            }
            else
            {
                return(PartialView("CannotAccessPage", "Shared"));
            }
        }
Exemple #2
0
        public async Task <IActionResult> Loan([Bind("AssetID", "UserID", "DateExpectedReturn")] LoanedAsset LA)
        {
            if (LoggedIn == false)
            {
                return(RedirectToAction("Index", "Login"));
            }

            int added = DAL.LoanAsset(LA);

            if (added != 0 && added != -1)
            {
                return(RedirectToAction("Edit", "Asset", DAL.GetAssetByID((int)LA.AssetID)));
            }
            ViewBag.NotAdded = true;
            return(View(DAL.GetAssetByID((int)LA.AssetID)));
        }
Exemple #3
0
        // GET: Asset/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (LoggedIn == false)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(NotFound());
            }
            else if (CurrentUser.Role.AssetsEdit)
            {
                {
                    LoanedAsset LA = DAL.GetLoanedAssetAndUserByAssetID((int)id);
                    if (LA != null)
                    {
                        ViewBag.LoanedAsset = LA;
                    }

                    return(View(DAL.GetAssetByID((int)id)));
                }
            }
            return(PartialView("CannotAccessPage", "Shared"));
        }