public ActionResult AddOrEdit(BAccountHolder emp)
 {
     try
     {
         if (emp.ImageUpload != null)
         {
             string fileName  = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName);
             string extension = Path.GetExtension(emp.ImageUpload.FileName);
             fileName      = fileName + DateTime.Now.ToString("yymmssfff") + extension;
             emp.ImagePath = "~/AppFiles/Images/" + fileName;
             emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName));
         }
         using (BankSystemDB_ArifEntities db = new BankSystemDB_ArifEntities())
         {
             if (emp.BAccountHolderID == 0)
             {
                 db.BAccountHolders.Add(emp);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(emp).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Submitted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Create([Bind(Include = "BranchID,BranchName,City")] Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branches.Add(branch);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(branch));
        }
        public ActionResult Create(EmployeeVM employeeVM)
        {
            if (ModelState.IsValid)
            {
                var employee = Mapper.Map <Employee>(employeeVM);
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeVM));
        }
        public ActionResult Create([Bind(Include = "LoanId,CustomerName,BranchID,IssueDate,PrincipleAmount,Interest,Total")] Loan loan)
        {
            if (ModelState.IsValid)
            {
                db.Loans.Add(loan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BranchID = new SelectList(db.Branches, "BranchID", "BranchName", loan.BranchID);
            return(View(loan));
        }
 public ActionResult Delete(int id)
 {
     try
     {
         using (BankSystemDB_ArifEntities db = new BankSystemDB_ArifEntities())
         {
             BAccountHolder emp = db.BAccountHolders.Where(x => x.BAccountHolderID == id).FirstOrDefault <BAccountHolder>();
             db.BAccountHolders.Remove(emp);
             db.SaveChanges();
         }
         return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult Add(Customer user)
 {
     _context.Customers.Add(user);
     _context.SaveChanges();
     return(Json(JsonRequestBehavior.AllowGet));
 }