public ActionResult Create([Bind(Include = "ID,Name,Address,Phone,Fax")] Branch branch) { var Currentuser = Session["CurrentUser"]; if (Currentuser == null) { return(RedirectToAction("Login", "Account")); } ViewBag.Currentuser = Currentuser; int userid = Convert.ToInt32(Currentuser); AspNetUser user = db.AspNetUsers.FirstOrDefault(a => a.Id == userid); ViewBag.UserRole = user.RoleID; var URL = Request.Url.AbsoluteUri; ViewBag.URL = URL; if (ModelState.IsValid) { db.Branches.Add(branch); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(branch)); }
public static void Person(int id, string name) { using (var db = new BankingSystemEntities()) { var person = db.People.FirstOrDefault(p => p.ID == id); if (person == null) { return; } person.Name = name; db.SaveChanges(); } }
public static void SavingsAccountAmount(Guid id, decimal amount) { using (var db = new BankingSystemEntities()) { var account = db.SavingsAccounts.FirstOrDefault(a => a.AccountId == id); if (account == null) { return; } account.Amount = amount; db.SaveChanges(); } }
public ActionResult Create(AspNetUser aspNetUser) { var Currentuser = Session["CurrentUser"]; if (Currentuser == null) { return(RedirectToAction("Login", "Account")); } ViewBag.Currentuser = Currentuser; var URL = Request.Url.AbsoluteUri; ViewBag.URL = URL; AspNetUser existinguser = db.AspNetUsers.FirstOrDefault(a => a.Name == aspNetUser.Name); if (existinguser != null) { ModelState.AddModelError("Name", "Already have in database!!!"); } if (ModelState.IsValid) { aspNetUser.CreatedDate = DateTime.Now; aspNetUser.BranchID = aspNetUser.BranchID; aspNetUser.UserName = aspNetUser.Name; aspNetUser.Password = "******"; db.AspNetUsers.Add(aspNetUser); db.SaveChanges(); return(RedirectToAction("Index")); } int userid = Convert.ToInt32(Currentuser); AspNetUser user = db.AspNetUsers.FirstOrDefault(a => a.Id == userid); ViewBag.UserRole = user.RoleID; ViewBag.ManagerID = new SelectList(db.AspNetUsers.Where(a => a.RoleID < 3 && a.BranchID == user.BranchID), "Id", "Name", aspNetUser.ManagerID); ViewBag.BranchID = new SelectList(db.Branches.Where(a => a.ID > 1), "ID", "Name", aspNetUser.BranchID); ViewBag.RoleID = new SelectList(db.AspNetRoles.Where(a => a.Id > user.RoleID), "ID", "Name", aspNetUser.RoleID); return(View(aspNetUser)); }
public static int Person(string name) { using (var db = new BankingSystemEntities()) { var person = new Person { Name = name }; db.People.Add(person); db.SaveChanges(); return(person.ID); } }
public static Guid CheckingsAccount(int personId, decimal amount) { using (var db = new BankingSystemEntities()) { var account = new CheckingsAccount { PersonId = personId, AccountId = Guid.NewGuid(), Amount = amount }; db.CheckingsAccounts.Add(account); db.SaveChanges(); return(account.AccountId); } }
public ActionResult Create([Bind(Include = "ID,CreateDate,LastUpdated,CategoryID,CustomerID,ToCustomerID,Amount,Fee,AfterFee,BranchID,UserID,Note")] Transition transition) { var Currentuser = Session["CurrentUser"]; if (Currentuser == null) { return(RedirectToAction("Login", "Account")); } ViewBag.Currentuser = Currentuser; int userid = Convert.ToInt32(Currentuser); AspNetUser user = db.AspNetUsers.FirstOrDefault(a => a.Id == userid); ViewBag.UserRole = user.RoleID; var URL = Request.Url.AbsoluteUri; ViewBag.URL = URL; decimal fee = Convert.ToDecimal(0.1); var BalanceCustomer = db.AllCustomerBalances.FirstOrDefault(a => a.ID == transition.CustomerID).Balance; if (transition.CategoryID != 1) { if (transition.Amount > BalanceCustomer) { ModelState.AddModelError("Amount", "Please filled the Amount less than Balance field"); } } if (ModelState.IsValid) { transition.CreateDate = DateTime.Now; transition.LastUpdated = DateTime.Now; if (user.BranchID != 1) { transition.BranchID = user.BranchID; } transition.UserID = userid; if (transition.CategoryID != 1) { transition.Fee = 0; transition.AfterFee = transition.Amount; } else { transition.Fee = (transition.Amount * fee) / 100; transition.AfterFee = transition.Amount - transition.Fee; } db.Transitions.Add(transition); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } if (transition.CategoryID != 1) { ViewBag.AfterFee = transition.Amount; } ViewBag.UserRole = user.RoleID; ViewBag.CategoryID = transition.CategoryID; ViewBag.Balance = BalanceCustomer.Value.ToString("#,##0.##"); ViewBag.BranchID = new SelectList(db.Branches.Where(a => a.ID > 1), "ID", "Name", transition.BranchID); ViewBag.CustomerID = new SelectList(db.Customers.Select(a => new { ID = a.ID, Value = a.IBANNo + " - " + a.Name }), "ID", "Value", transition.CustomerID); ViewBag.ToCustomerID = new SelectList(db.Customers.Select(a => new { ID = a.ID, Value = a.IBANNo + " - " + a.Name }), "ID", "Value", transition.ToCustomerID); return(View(transition)); }
public ActionResult Create([Bind(Include = "ID,IBANNo,CardID,Name,BranchID,CreateDate,BirthDate,Email,Address,Phone1,Phone2")] Customer customer) { var Currentuser = Session["CurrentUser"]; if (Currentuser == null) { return(RedirectToAction("Login", "Account")); } ViewBag.Currentuser = Currentuser; var URL = Request.Url.AbsoluteUri; ViewBag.URL = URL; int userid = Convert.ToInt32(Currentuser); AspNetUser user = db.AspNetUsers.FirstOrDefault(a => a.Id == userid); ViewBag.UserRole = user.RoleID; if (customer.CardID == null) { ModelState.AddModelError("CardID", "Please filled the CardID field"); } if (customer.BirthDate == null) { ModelState.AddModelError("BirthDate", "Please filled the BirthDate field"); } if (customer.Email == null) { ModelState.AddModelError("Email", "Please filled the Email field"); } if (customer.Name == null) { ModelState.AddModelError("Name", "Please filled the Name field"); } if (ModelState.IsValid) { customer.IBANNo = TempData["IbanNoCode"].ToString(); customer.CreateDate = DateTime.Now; if (user.BranchID != 1) { customer.BranchID = user.BranchID; } db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } var js = new MSScriptControl.ScriptControlClass { AllowUI = false, Language = "JScript" }; js.Reset(); string jscode = ReadResource(); js.AddCode(jscode); object[] parms = new object[] { "Netherlands" }; string result = (string)js.Run("buildIbans", ref parms); ViewBag.IbanNo = result; TempData["IbanNoCode"] = result; ViewBag.UserRole = user.RoleID; ViewBag.BranchID = new SelectList(db.Branches.Where(a => a.ID > 1), "ID", "Name", customer.BranchID); return(View(customer)); }