public bool NewPackageSubscription(InvestmentCreateModel model, HttpPostedFileBase ReceiptFile, int userId) { try { if (ReceiptFile.IsImage()) { string fileExt = Path.GetExtension(ReceiptFile.FileName); string newFileName = (DBConstant.UploadReceiptPrefix + DateTime.UtcNow.ConvertToPlainDateTimeString() + Guid.NewGuid().ToString() + fileExt).ToLower(); new ImageController().Upload(ConfigurationManager.AppSettings["UploadReceiptPhotoPath"], ReceiptFile, newFileName); var package = _investmentService.GetEntitledPackage(model.Amount); UserPackage up = new UserPackage { PackageId = package.PackageId, UserId = userId, TotalAmount = model.Amount, CreatedTimestamp = DateTime.UtcNow, ReceiptBank = model.Bank, ReceiptImagePath = newFileName, ReceiptNo = model.ReferenceNo ?? "", InterestRate = package.Rate, StatusId = (int)EStatus.Pending, }; _investmentService.InsertUserPackage(up); return(_investmentService.SaveChange(userId)); } } catch (Exception ex) { Log.Error(ex.Message, ex); } return(false); }
public IActionResult Create(InvestmentCreateModel createModel) { var createInfo = ObjectMapperHelper.Map <InvestmentCreateInfo>(createModel); createInfo.Investor = JieshaiManager.Instace.InvestorManager.GetById(createModel.InvestorId); var investor = JieshaiManager.Instace.InvestmentManager.Create(createInfo); return(this.RedirectToAction("Index")); }
public ActionResult Create(InvestmentCreateModel model, HttpPostedFileBase ReceiptFile) { try { //Validation if (!ReceiptFile.IsImage()) { ModelState.AddModelError("", "Invalid upload file format."); } string fileExt = Path.GetExtension(ReceiptFile.FileName); string newFileName = (DBConstant.UploadReceiptPrefix + DateTime.UtcNow.ConvertToPlainDateTimeString() + Guid.NewGuid().ToString() + fileExt).ToLower(); new ImageController().Upload(ConfigurationManager.AppSettings["UploadReceiptPhotoPath"], ReceiptFile, newFileName); if (ModelState.IsValid) { var package = _investmentService.GetEntitledPackage(model.Amount); if (NewPackageSubscription(model, ReceiptFile, User.Identity.GetUserId <int>())) { Success("Added new package " + package.Description + " and pending for approval."); } else { Warning("Something wrong while we add your new package.\n If problem persist please contact our customer service.", false); } } else { return(View(model)); } } catch (Exception ex) { Danger("Something wrong while we process your request, please try again later.\n If problem persist please contact our customer service.", false); Log.Error(ex.Message, ex); } return(RedirectToAction("Index")); }
public ActionResult Setup(SetupViewModel model, HttpPostedFileBase ReceiptFile) { var currentUser = _userService.GetUserBy(User.Identity.GetUserId <int>()); if (ModelState.IsValid) { InvestmentCreateModel investmentCreateModel = new InvestmentCreateModel { Bank = model.Bank, Date = model.Date, Amount = model.Amount, ReceiptFile = ReceiptFile, ReferenceNo = model.ReferenceNo }; var isSuccess = new InvestmentController(_investmentService, _userService).NewPackageSubscription(investmentCreateModel, ReceiptFile, currentUser.UserId); if (isSuccess) { currentUser.IsFirstTimeLogIn = false; _userService.UpdateUser(currentUser); _userService.SaveChanges(User.Identity.GetUserId <int>()); return(RedirectToAction("SetupComplete")); } else { return(View("Error")); } } model.PackageList = _investmentService.GetAllPackage().ToList().Select(x => new SetupViewModel.PackageInfo { PackageDescription = x.Description, PackageThreshold = x.Threshold.toCurrencyFormat(), ReturnRate = (x.Rate * 100).ToString("#0.00") + "%", styleClass = x.Description }).ToList(); return(View(model)); }
public ActionResult Create() { InvestmentCreateModel model = new InvestmentCreateModel(); return(View()); }