Пример #1
0
        public async Task <IActionResult> Create(CostEntryCreateViewModel model)
        {
            var success = await this.costEntryService
                          .CreateAsync(model.DateCreated, model.CostEntryTypeId, model.VehicleId, model.Price, model.CurrencyId.Value, model.Note, model.Odometer);

            if (!success)
            {
                this.ShowNotification(NotificationMessages.CostEntryUpdateFailed);
                return(RedirectToAction(nameof(Create), new { id = model.VehicleId }));
            }

            this.ShowNotification(NotificationMessages.CostEntryAddedSuccessfull, NotificationType.Success);

            return(RedirectToVehicle(model.VehicleId));
        }
Пример #2
0
        public async Task <IActionResult> Create(int id)
        {
            var user = await this.userManager.GetUserAsync(User);

            var model = new CostEntryCreateViewModel
            {
                DateCreated       = this.dateTimeProvider.GetCurrentDateTime(),
                VehicleId         = id,
                CurrencyId        = user.CurrencyId,
                AllCostEntryTypes = await this.GetAllCostEntryTypes(),
                AllCurrencies     = await this.GetAllCurrenciesAsync()
            };

            return(View(model));
        }