public ActionResult Create([Bind(Include = "Loan, LoanDecision, MainWorkPlace, ApprovedAmount, NetAmount, ProfitAmount")] OutgoingLoan outgoingLoan)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (ModelState.IsValid)
            {
                try
                {
                    OutgoingLoanServices.Insert(CurrentUser.Id, outgoingLoan, db);
                    TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "InsertConfirmed");
                    return(RedirectToAction("Index"));
                }
                catch (CfException cfex)
                {
                    TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
                }
                catch (Exception ex)
                {
                    TempData["Failure"] = ex.Message;
                }
            }

            ViewBag.LoanList          = new SelectList(LoanServices.List(db), "Product", "Name");
            ViewBag.LoanDecisionList  = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber");
            ViewBag.MainWorkPlaceList = new SelectList(MainWorkPlaceServices.List(db), "Id", "Name");
            return(View(outgoingLoan));
        }
        // GET: OutgoingLoan/Delete/5
        public ActionResult Delete(Nullable <int> id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Db           db           = new Db(DbServices.ConnectionString);
            OutgoingLoan outgoingLoan = OutgoingLoanServices.Get(id.Value, db);

            if (outgoingLoan == null)
            {
                return(HttpNotFound());
            }
            return(View(outgoingLoan));
        }
 public ActionResult DeleteConfirmed(int loan)
 {
     try
     {
         Db db = new Db(DbServices.ConnectionString);
         OutgoingLoanServices.Delete(CurrentUser.Id, loan, db);
         TempData["Success"] = ResourceServices.GetString(Cf.Data.Resources.ResourceBase.Culture, "UI", "DeleteConfirmed");
         // return RedirectToAction("Index");
     }
     catch (CfException cfex)
     {
         TempData["Failure"] = cfex.ErrorDefinition.LocalizedMessage;
     }
     catch (Exception ex)
     {
         TempData["Failure"] = ex.Message;
     }
     // return View(outgoingLoan);
     return(RedirectToAction("Index"));
 }
        // GET: OutgoingLoan/Edit/5
        public ActionResult Edit(Nullable <int> loan)
        {
            Db db = new Db(DbServices.ConnectionString);

            if (loan == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OutgoingLoan outgoingLoan = OutgoingLoanServices.Get(loan.Value, db);

            if (outgoingLoan == null)
            {
                return(HttpNotFound());
            }

            ViewBag.LoanList          = new SelectList(LoanServices.List(db), "Product", "Name", outgoingLoan.Loan);
            ViewBag.LoanDecisionList  = new SelectList(LoanDecisionServices.List(db), "Id", "CersNumber", outgoingLoan.LoanDecision);
            ViewBag.MainWorkPlaceList = new SelectList(MainWorkPlaceServices.List(db), "Id", "Name", outgoingLoan.MainWorkPlace);
            return(View(outgoingLoan));
        }