public ActionResult Create(PurchaseCooperative purchasecooperative)
        {
            if (ModelState.IsValid)
            {
                _db.PurchaseCooperatives.Add(purchasecooperative);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(purchasecooperative);
        }
        public ActionResult Join(JoinLeaseViewModel viewModel)
        {
            var clientId = (int)ViewData["UserId"];
            var client = _db.Clients.Find(viewModel.Client.UserId);
            var lease = viewModel.Lease;
            client.DepositAmount += viewModel.Client.DepositAmount;

            var pc = new PurchaseCooperative();
            pc.Clients = new List<Client>();
            pc.Clients.Add(client);
            pc.Lease = lease;
            pc.AmountFinanced = 0;

            pc.AmountFinanced += viewModel.Client.DepositAmount;

            _db.PurchaseCooperatives.Add(pc);
            _db.SaveChanges();

            return RedirectToAction("Index");

            //            return View(viewModel);
        }
 public ActionResult Edit(PurchaseCooperative purchasecooperative)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(purchasecooperative).State = EntityState.Modified;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(purchasecooperative);
 }