public ActionResult CreditAccount(CustomerSavings customersavings) { var customerAccount = db.CustomerSavings.Where(m => m.AccountNo == customersavings.AccountNo); if (ModelState.IsValid) { foreach (var item in customerAccount) { if (item.AccountNo == null) { return(View("AccountNotFound")); } } //customersavings.DateCreated = DateTime.Now.ToString(); customersavings.DateCreated = DateTime.Now; customersavings.Transactionby = User.Identity.Name.ToString(); customersavings.Debit = 0; db.CustomerSavings.Add(customersavings); db.SaveChanges(); //return RedirectToAction("~/CustomerSavings/Details/"+customersavings.Id); return(Redirect("~/CustomerSavings/Details/" + customersavings.Id)); } return(View(customersavings)); }
public ActionResult DeleteConfirmed(int id) { CustomerSavings customersavings = db.CustomerSavings.Find(id); db.CustomerSavings.Remove(customersavings); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: /CustomerSavings/Details/5 public ActionResult Details(int id = 0) { CustomerSavings customersavings = db.CustomerSavings.Find(id); if (customersavings == null) { return(HttpNotFound()); } return(View(customersavings)); }
public ActionResult Edit(CustomerSavings customersavings) { if (ModelState.IsValid) { db.Entry(customersavings).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customersavings)); }
public ActionResult Create(Customer customer, HttpPostedFileBase file) { if (ModelState.IsValid) { string imageName = string.Empty; if (file != null && file.ContentLength > 0) { string extension = Path.GetExtension(file.FileName); if (extension != ".jpg" && extension != ".jpeg" && extension != ".png") { ModelState.AddModelError("Invalid Image", "Please upload .jpg or .png image."); return(View(customer)); } imageName = Guid.NewGuid() + extension; customer.ImageUrl = ConfigurationManager.AppSettings["Azure:StorageUrl"] + BlobContainer.customer.ToString() + "/" + imageName; } string CustomerAccountNo = new Random().Next(10000, 90000).ToString(); customer.AccountNo = CustomerAccountNo; customer.DateCreated = DateTime.Now.ToShortDateString(); db.Customers.Add(customer); //Credit the customer's account with seed money var credit = new CustomerSavings { AccountNo = CustomerAccountNo, Credit = 0, Debit = 0, //DateCreated=DateTime.Now.ToShortDateString(), DateCreated = DateTime.Now, Name = customer.Name, Transactionby = User.Identity.Name, }; db.CustomerSavings.Add(credit); db.SaveChanges(); //Fire and forget cron-job for dividend generation for this customer //new DenariCronJobs().initateDividends(CustomerAccountNo); if (file != null && file.ContentLength > 0) { FileHelper.UploadImage(file.InputStream, imageName, BlobContainer.customer); } return(Redirect("~/Customer/Details/" + customer.CustomerId)); } return(View(customer)); }
public ActionResult DeleteConfirmed(int id) { Customer customer = db.Customers.Find(id); CustomerSavings customerSavings = db.CustomerSavings.Find(db.CustomerSavings.Where(x => x.AccountNo == customer.AccountNo).Select(x => x.Id).FirstOrDefault()); FileHelper.DeleteBlob(BlobContainer.customer, customer.ImageUrl); db.Customers.Remove(customer); db.CustomerSavings.Remove(customerSavings); db.SaveChanges(); return(RedirectToAction("Index")); }