public ActionResult Index()
        {
            AccountDataViewModel accountData = new AccountDataViewModel();

            accountData.Sales    = new List <Sale>();
            accountData.Services = new List <Service>();
            accountData.discount = 0;

            List <Sale> customerSales = db.Sales.Where(sales => sales.Customer.AspNetUser.UserName == User.Identity.Name).OrderByDescending(date => date.date).Take(3).ToList();

            if (customerSales.Count() > 0)
            {
                accountData.Sales = customerSales;
            }

            List <Service> customerServices = db.Services.Where(sales => sales.Customer.AspNetUser.UserName == User.Identity.Name).OrderByDescending(date => date.dateOfEmployment).Take(3).ToList();

            if (customerServices.Count() > 0)
            {
                accountData.Services = customerServices;
            }

            List <Customer> custs = db.Customers.Where(cust => cust.AspNetUser.UserName == User.Identity.Name).ToList();

            if (custs.Count() > 0)
            {
                accountData.discount = (custs.First().PermanentDiscount_idPermanentDiscount != null) ? custs.First().PermanentDiscount.discount : 0;
            }

            return(View(accountData));
        }
Example #2
0
        public async Task <IdentityResult> UpdateAccountData(AccountDataViewModel accountDataViewModel, string applicationUserId)
        {
            var applicationUser = await applicationUserService.GetApplicationUserById(applicationUserId);

            var updatedApplicationUser = mapper.Map(accountDataViewModel, applicationUser);

            return(await accountService.UpdateAccountData(updatedApplicationUser));
        }
Example #3
0
        public async Task <IActionResult> Index()
        {
            ApplicationUser applicationUser = await GetCurrentUser();

            AccountDataViewModel accountDataViewModel = new AccountDataViewModel
            {
                Name           = applicationUser.UserName,
                Email          = applicationUser.Email,
                EmailConfirmed = applicationUser.EmailConfirmed
            };

            return(View(accountDataViewModel));
        }
Example #4
0
 public ActionResult AjaxIndex(AccountDataViewModel data)
 {
     if (ModelState.IsValid)
     {
         //UnitOfWork
         _moneyTemplateService.Add(new AccountBook {
             Id = data.Id, Dateee = data.DateTime, Categoryyy = (int)data.AccountType, Amounttt = data.Money, Remarkkk = $"{data.Remark}"
         });
         //_logService.AddLog(new AccountBook { Dateee = System.DateTime.Now, Categoryyy = 0, Amounttt = 200 });
         _unitOfWork.Commit();
         ModelState.AddModelError("", "新增成功");
         return(View());
     }
     else
     {
         ModelState.AddModelError("", "新增失敗");
         return(View(data));
     }
 }