public async Task <ActionResult> DeleteConfirmed(int id)
        {
            PurchasePCComponent purchasePCComponent = await context.PurchasePCComponents.FindAsync(id);

            context.PurchasePCComponents.Remove(purchasePCComponent);
            await context.SaveChangesAsync();

            TempData["SuccessMessage"] = "Запись удалена";
            return(RedirectToAction("Index"));
        }
        // GET: PurchasePCComponents/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchasePCComponent purchase = await context.PurchasePCComponents.FindAsync(id);

            if (purchase == null)
            {
                return(HttpNotFound());
            }
            return(View(purchase));
        }
        public async Task <ActionResult> Create([Bind(Include = "PurchaseComponentId,ComponentId,ModelId,SupplierId,Availabity,Specifications,Price,GuaranteePeriod,DateIssue")] PurchasePCComponent purchase)
        {
            if (ModelState.IsValid)
            {
                context.Entry(purchase).State = EntityState.Added;
                await context.SaveChangesAsync();

                TempData["SuccessMessage"] = "Запись добавлена";
                return(RedirectToAction("Index"));
            }
            ViewBag.ComponentId = new SelectList(context.Components, "ComponentId", "ComponentName", purchase.ComponentId);
            ViewBag.SupplierId  = new SelectList(context.Suppliers, "SupplierId", "SupplierFirm", purchase.SupplierId);
            ViewBag.ModelId     = new SelectList(context.Models, "ModelId", "ModelName", purchase.ModelId);
            return(View(purchase));
        }
        // GET: PurchasePCComponents/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchasePCComponent purchase = await context.PurchasePCComponents.FindAsync(id);

            if (purchase == null)
            {
                HttpNotFound();
            }
            ViewBag.ComponentId = new SelectList(context.Components, "ComponentId", "ComponentName");
            ViewBag.SupplierId  = new SelectList(context.Suppliers, "SupplierId", "SupplierFirm");
            ViewBag.ModelId     = new SelectList(context.Models, "ModelId", "ModelName");
            return(View(purchase));
        }