Example #1
0
 public ActionResult Create(AccountViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _accountLogic.AddAccount(model, Convert.ToInt32(HttpContext.Session.GetInt32("UserId")));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View("CreateBill"));
     }
 }
        public async Task <IActionResult> RegisterUser(RegisterUserViewModel viewModel)
        {
            var    user                 = viewModel.User;
            var    account              = viewModel.Account;
            var    accountImage         = viewModel.AccountImage;
            string accountImageFileName = accountImage.FileName;

            account.Image = accountImageFileName;
            accountLogic.AddAccount(user, account);

            //Add image to root of app
            string mapRoot = "images/UserImages/";

            var accountImagePath = Path.Combine(_hostingEnvironment.WebRootPath, mapRoot);

            await AddFileToDirectory(accountImage, accountImagePath);

            return(View());
        }