public async Task <IActionResult> UpsertTransaction(UpsertTransactionViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (model.Transaction.Id > 0)
                    {
                        await _transactionService.UpdateTransactionForCurrentUser(model.Transaction);

                        return(Json(new SinanceJsonResult
                        {
                            Success = true
                        }));
                    }
                    else
                    {
                        await _transactionService.CreateTransactionForCurrentUser(model.Transaction);

                        return(Json(new SinanceJsonResult
                        {
                            Success = true
                        }));
                    }
                }
                catch (NotFoundException)
                {
                    TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.BankAccountNotFound);
                }
            }

            return(PartialView("UpsertTransactionPartial", model));
        }
Beispiel #2
0
        public async Task <IActionResult> SaveImport(ImportModel model)
        {
            try
            {
                var(skippedTransactions, savedTransactions) = await _importService.SaveImport(model);

                var message = string.Format(CultureInfo.CurrentCulture, Resources.TransactionsAddedAndSkippedFormat, savedTransactions, skippedTransactions);

                TempDataHelper.SetTemporaryMessage(tempData: TempData,
                                                   state: savedTransactions != 0 ? MessageState.Success : MessageState.Warning,
                                                   message: message);
                return(RedirectToAction("Index", "AccountOverview", new { @bankAccountId = model.BankAccountId }));
            }
            catch (NotFoundException exc)
            {
                if (exc.ItemName == nameof(ImportModel))
                {
                    TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.ImportTimeOut);
                }
                else
                {
                    TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.BankAccountNotFound);
                }
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Edit action for custom reports
        /// </summary>
        /// <param name="reportId">Identifier of the report to edit</param>
        /// <returns>View with the custom report to edit</returns>
        public async Task <IActionResult> EditCustomReport(int reportId)
        {
            var allCategories = await _categoryService.GetAllCategoriesForCurrentUser();

            try
            {
                var report = await _customReportService.GetCustomReportByIdForCurrentUser(reportId);

                var availableCategories = allCategories.Select(category => new BasicCheckBoxItem
                {
                    Id      = category.Id,
                    Name    = category.Name,
                    Checked = report.Categories.Any(reportCategory => reportCategory.CategoryId == category.Id)
                }).ToList();

                return(View("UpsertCustomReport", new UpsertCustomReportModel
                {
                    AvailableCategories = availableCategories,
                    CustomReport = report
                }));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CustomReportNotFound);
                return(View("Home", "Index"));
            }
        }
        public IActionResult Index(Journey journey)
        {
            var emailObj = TempDataHelper.Get(Statics.EmailTempData);

            TempDataHelper.Remove(Statics.EmailTempData);

            string password = journey.Password;

            journey          = _wrapper.GetJourney(emailObj);
            journey.Password = password;

            journey.CurrentPage = "About You";

            if (!journey.Registered)
            {
                var user = new User(journey.Email, 0, DateTime.Now, DateTime.Now, Guid.NewGuid())
                {
                    PrimaryEmail    = journey.Email,
                    CurrentPassword = journey.Password
                };

                _wrapper.RegisterUser(user);
                journey.Registered = true;
                _wrapper.PutJourney(journey);
            }

            return(View(journey));
        }
Beispiel #5
0
        public async Task <IActionResult> Import(IFormFile file, ImportModel model)
        {
            try
            {
                using var stream = file.OpenReadStream();

                await _importService.CreateImportPreview(stream, model);

                return(View("ImportResult", model));
            }
            catch (NotFoundException exc)
            {
                Log.Error(exc, "Exception during Import");

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, message: Resources.BankAccountNotFound);
                return(RedirectToAction("Index"));
            }
            catch (ImportFileException exc)
            {
                Log.Error(exc, "Exception during Import");

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, message: Resources.ErrorWhileProcessingImport);
                return(RedirectToAction("Index"));
            }
            catch (Exception exc)
            {
                Log.Error(exc, "Exception during Import");

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, message: Resources.Error);
                return(RedirectToAction("Index"));
            }
        }
        /// <summary>
        /// Starts the edit action for a model
        /// </summary>
        /// <param name="transactionId">Id of the model to edit</param>
        /// <returns>Partial view for editing the model</returns>
        public async Task <IActionResult> EditTransaction(int transactionId)
        {
            try
            {
                var transaction = await _transactionService.GetTransactionByIdForCurrentUser(transactionId);

                var userCategories = await _categoryService.GetAllCategoriesForCurrentUser();

                var availableCategories = CreateAvailableCategoriesSelectList(userCategories);

                var model = new UpsertTransactionViewModel
                {
                    AvailableCategories = availableCategories,
                    Transaction         = transaction
                };

                return(PartialView("UpsertTransactionPartial", model));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.TransactionNotFound);
            }

            return(View("Index"));
        }
        // GET
        public IActionResult Index(Journey journey)
        {
            var email = Request.Query["email"];

            if (email.Count != 0)
            {
                journey = _wrapper.GetJourney(email[0]);
                TempDataHelper.Set(Statics.EmailTempData, email);
            }
            else
            {
                string emailObj = TempDataHelper.Get(Statics.EmailTempData);

                if (emailObj != null)
                {
                    journey = _wrapper.GetJourney(emailObj);
                }
                else
                {
                    journey = new Journey();
                }
            }

            journey.CurrentPage = "Welcome";

            return(View(journey));
        }
Beispiel #8
0
        public IActionResult SaveData()
        {
            var currentVm = TempDataHelper.Get <LightFeedbackVm>(TempData, _feedbackTempDataKey);

            _lightFeedbackService.SaveFeedBack(currentVm);
            return(PartialView("Complete"));
        }
Beispiel #9
0
        public IActionResult CreateSaved(Pricetranfer pricetranfer)
        {
            StatusQuery Notification;

            if (ModelState.IsValid)
            {
                try
                {
                    _pricetranfer.Insert(pricetranfer);
                    var statusInsert = _pricetranfer.SaveChanges();
                    if (statusInsert > 0)
                    {
                        TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Thêm thành công"));
                        return(RedirectToAction("Index", "Tranfer"));
                    }
                    else
                    {
                        Notification   = new StatusQuery("error", "", "Thêm mới thất bại");
                        ViewBag.Status = Notification.Status;
                        ViewBag.Value  = Notification.Value;
                        ViewBag.Type   = Notification.Type;
                    }
                }
                catch (Exception)
                {
                    return(View(pricetranfer));
                }
            }
            else
            {
                return(View(pricetranfer));
            }
            return(View(pricetranfer));
        }
        public ActionResult Create(Favourite favourite)
        {
            StatusQuery Notification;

            if (ModelState.IsValid)
            {
                try
                {
                    _favouriteRepo.Insert(favourite);
                    var statusInsert = _favouriteRepo.SaveChanges();
                    if (statusInsert > 0)
                    {
                        TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Thêm thành công"));
                        return(RedirectToAction("Index", "Favourite"));
                    }
                    else
                    {
                        Notification   = new StatusQuery("error", "", "Thêm mới thất bại");
                        ViewBag.Status = Notification.Status;
                        ViewBag.Value  = Notification.Value;
                        ViewBag.Type   = Notification.Type;
                    }
                }
                catch (Exception)
                {
                    return(View(favourite));
                }
            }
            return(View(favourite));
        }
        /// <summary>
        /// Index action for account overview
        /// </summary>
        /// <param name="bankAccountId">Id of the bank account to show</param>
        /// <returns>View containing the overview</returns>
        public async Task <IActionResult> Index(int bankAccountId)
        {
            try
            {
                var bankAccount = await _bankAccountService.GetBankAccountByIdForCurrentUser(bankAccountId);

                var transactions = await _transactionService.GetTransactionsForBankAccountForCurrentUser(bankAccountId, 200, skip : 0);

                var availableCategories = await _categoryService.GetAllCategoriesForCurrentUser();

                var model = new AccountOverviewViewModel
                {
                    Account             = bankAccount,
                    Transactions        = transactions.Take(200).ToList(),
                    AccountBalance      = bankAccount.CurrentBalance.GetValueOrDefault(),
                    AvailableCategories = availableCategories
                };

                return(View("index", model));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.BankAccountNotFound);
                return(RedirectToAction(actionName: "Index", controllerName: "Home"));
            }
        }
Beispiel #12
0
        private LightFeedbackVm UpdateTempData(LightFeedbackVm lightingSurveyVm, bool displaySameView)
        {
            var currentVm       = TempDataHelper.Get <LightFeedbackVm>(TempData, _feedbackTempDataKey);
            var updatedTempData = _tempDataService.UpdateTempData(currentVm, lightingSurveyVm, displaySameView);

            TempDataHelper.Put <LightFeedbackVm>(TempData, _feedbackTempDataKey, updatedTempData);
            return(updatedTempData);
        }
Beispiel #13
0
        public IActionResult GetViewById(int viewId)
        {
            var feedbackTempData = TempDataHelper.Get <LightFeedbackVm>(TempData, _feedbackTempDataKey);
            var viewToDisplay    = _lightFeedbackService.GetFeedbackQuestion(viewId);

            feedbackTempData.CurrentStep = viewId;
            TempDataHelper.Put <LightFeedbackVm>(TempData, _feedbackTempDataKey, feedbackTempData);
            return(PartialView(viewToDisplay, feedbackTempData));
        }
Beispiel #14
0
        public IActionResult Index()
        {
            var currentView = new LightFeedbackVm()
            {
                FullNameVm  = new FullNameVm(),
                EmailVm     = new EmailVm(),
                HomeAddress = new AddressVm(),
                CurrentStep = 1
            };

            TempDataHelper.Put <LightFeedbackVm>(TempData, _feedbackTempDataKey, currentView);
            return(View(currentView));
        }
Beispiel #15
0
        public IActionResult Create()
        {
            StatusQuery Notification;

            Notification = TempDataHelper.Get <StatusQuery>(TempData, "Notification");
            if (Notification != null)
            {
                ViewBag.Status = Notification.Status;
                ViewBag.Value  = Notification.Value;
                ViewBag.Type   = Notification.Type;
            }
            return(View());
        }
        public IActionResult DeleteChanged(int id)
        {
            var _formationdelete = _formation.GetById(id);

            _formation.Delete(_formationdelete);
            var statusdelete = _formation.SaveChanges();

            if (statusdelete > 0)
            {
                TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("error", "", "Xoá thành công"));
            }
            return(RedirectToAction("Index", "Information"));
        }
Beispiel #17
0
        /// <summary>
        /// Upserts a category mapping to the database
        /// </summary>
        /// <param name="model">Model to upsert</param>
        /// <returns>Result of the upsert</returns>
        public async Task <IActionResult> UpsertCategoryMapping(CategoryMappingModel model)
        {
            if (ModelState.IsValid)
            {
                // Placeholder extra validation, in the future all mappings should be possible
                if (model.ColumnTypeId != ColumnType.Description &&
                    model.ColumnTypeId != ColumnType.Name &&
                    model.ColumnTypeId != ColumnType.DestinationAccount)
                {
                    ModelState.AddModelError("", Resources.UnsupportedColumnTypeMapping);
                    return(PartialView("UpsertCategoryMapping", model));
                }

                if (model.Id > 0)
                {
                    try
                    {
                        await _categoryMappingService.UpdateCategoryMappingForCurrentUser(model);

                        return(Json(new SinanceJsonResult
                        {
                            Success = true
                        }));
                    }
                    catch (NotFoundException)
                    {
                        TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryMappingNotFound);
                        return(PartialView("UpsertCategoryMapping", model));
                    }
                }
                else
                {
                    try
                    {
                        await _categoryMappingService.CreateCategoryMappingForCurrentUser(model);

                        return(Json(new SinanceJsonResult
                        {
                            Success = true
                        }));
                    }
                    catch (NotFoundException)
                    {
                        TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryNotFound);
                        return(PartialView("UpsertCategoryMapping", model));
                    }
                }
            }

            return(PartialView("UpsertCategoryMapping", model));
        }
        /// <summary>
        /// Start an edit account action
        /// </summary>
        /// <param name="accountId">Id of account to edit</param>
        /// <returns>Actionresult with details of the account</returns>
        public async Task <IActionResult> EditAccount(int accountId)
        {
            try
            {
                var bankAccount = await _bankAccountService.GetBankAccountByIdForCurrentUser(accountId);

                return(View("UpsertAccount", bankAccount));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.BankAccountNotFound);
                return(RedirectToAction("Index"));
            }
        }
Beispiel #19
0
        public IActionResult Index()
        {
            StatusQuery Notification;
            var         _listranfer = _pricetranfer.GetAll();

            Notification = TempDataHelper.Get <StatusQuery>(TempData, "Notification");
            if (Notification != null)
            {
                ViewBag.Status = Notification.Status;
                ViewBag.Value  = Notification.Value;
                ViewBag.Type   = Notification.Type;
            }
            return(View(_listranfer));
        }
Beispiel #20
0
        /// <summary>
        /// Starts the process of editing a category mapping
        /// </summary>
        /// <param name="categoryMappingId">Category mapping to edit</param>
        /// <returns>Partial view to edit the mapping</returns>
        public async Task <IActionResult> EditCategoryMapping(int categoryMappingId)
        {
            try
            {
                var model = await _categoryMappingService.GetCategoryMappingByIdForCurrentUser(categoryMappingId);

                return(PartialView("UpsertCategoryMapping", model));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryMappingNotFound);
                return(View("Index"));
            }
        }
        /// <summary>
        /// Deletes a model
        /// </summary>
        /// <param name="transactionId">Id of model to delete</param>
        /// <returns>Result of the delete action</returns>
        public async Task <IActionResult> DeleteTransaction(int transactionId, int bankAccountId)
        {
            try
            {
                await _transactionService.DeleteTransactionForCurrentUser(transactionId);

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Success, Resources.TransactionDeleted);
                return(RedirectToAction("Index", new { bankAccountId }));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.TransactionNotFound);
                return(RedirectToAction("Index", "Home"));
            }
        }
        /// <summary>
        /// Removes the given account
        /// </summary>
        /// <param name="accountId">Id of account to remove</param>
        /// <returns>ActionResult with details of the remove action</returns>
        public async Task <IActionResult> RemoveAccount(int accountId)
        {
            try
            {
                await _bankAccountService.DeleteBankAccountByIdForCurrentUser(accountId);

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Success, Resources.BankAccountRemoved);
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.BankAccountNotFound);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #23
0
        public IActionResult DeleteConfirm(int id)
        {
            var _vehicle = _vehicletypeRepository.GetById(id);

            _vehicletypeRepository.Delete(_vehicle);
            var statusDelete = _vehicletypeRepository.SaveChanges();

            if (statusDelete > 0)
            {
                TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Xoa thanh cong"));
                return(RedirectToAction("Create", "VehicleType"));
            }

            return(RedirectToAction("Index"));
        }
Beispiel #24
0
        /// <summary>
        /// Removes a category mapping from the database
        /// </summary>
        /// <param name="categoryMappingId">Id of the mapping to remove</param>
        /// <returns>Redirect to the edit category view</returns>
        public async Task <IActionResult> RemoveCategoryMapping(int categoryMappingId, int categoryId)
        {
            try
            {
                await _categoryMappingService.DeleteCategoryMappingByIdForCurrentUser(categoryMappingId);

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Success, Resources.CategoryMappingDeleted);
                return(RedirectToAction("EditCategory", "Category", new { categoryId }));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryMappingNotFound);
                return(RedirectToAction("Index", "Category"));
            }
        }
Beispiel #25
0
        /// <summary>
        /// Assigns the category to the previously previewed transactions
        /// </summary>
        /// <param name="categoryId">Id of the category to assign</param>
        /// <returns>Redirect to the edit category action</returns>
        public async Task <IActionResult> UpdateCategoryToMappedTransactions(int categoryId, IEnumerable <int> transactionIds)
        {
            try
            {
                await _categoryService.MapCategoryToTransactionsForCurrentUser(categoryId, transactionIds);

                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Success, Resources.CategoryMappingsAppliedToTransactions);

                return(RedirectToAction("EditCategory", new { categoryId }));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryNotFound);
                return(RedirectToAction("Index"));
            }
        }
Beispiel #26
0
        public IActionResult Index()
        {
            var lightFeedbackVm = TempDataHelper.Get <LightFeedbackVm>(TempData, _feedbackTempDataKey);

            if (lightFeedbackVm == null)
            {
                lightFeedbackVm = _tempDataService.InitialiseViewModel();
            }
            else
            {
                lightFeedbackVm.CurrentStep = 1;
            }

            TempDataHelper.Put <LightFeedbackVm>(TempData, _feedbackTempDataKey, lightFeedbackVm);
            return(View(lightFeedbackVm));
        }
        public IActionResult Index()
        {
            StatusQuery Notification;

            Notification = TempDataHelper.Get <StatusQuery>(TempData, "Notification");
            if (Notification != null)
            {
                ViewBag.Status = Notification.Status;
                ViewBag.Value  = Notification.Value;
                ViewBag.Type   = Notification.Type;
            }
            var _listInfor = _formation.GetAll();
            List <InformationModel> ListInformationTypeModel = new List <InformationModel>();

            foreach (var item in _listInfor)
            {
                if (item.Status)
                {
                    var informmodel = new InformationModel()
                    {
                        Descreption = "Huyền thoại bóng đá",
                        Name        = item.Name,
                        Id          = item.Id,
                        Number      = item.Number,
                        Club        = item.Club,
                        Status      = item.Status,
                        Image       = item.Image
                    };
                    ListInformationTypeModel.Add(informmodel);
                }
                else
                {
                    var informmodel = new InformationModel()
                    {
                        Descreption = "Siêu sao bóng đá",
                        Name        = item.Name,
                        Id          = item.Id,
                        Number      = item.Number,
                        Club        = item.Club,
                        Status      = item.Status,
                        Image       = item.Image
                    };
                    ListInformationTypeModel.Add(informmodel);
                }
            }
            return(View(ListInformationTypeModel));
        }
        // GET
        public IActionResult Index(Journey journey)
        {
            var emailObj = TempDataHelper.Get(Statics.EmailTempData);

            if (!string.IsNullOrEmpty(emailObj))
            {
                journey = _wrapper.GetJourney(emailObj);
            }
            else
            {
                journey = new Journey();
            }

            journey.CurrentPage = "Register";

            return(View(journey));
        }
        public ActionResult Edit(Favourite model)
        {
            var editfavourite = _favouriteRepo.GetById(model.Id);

            editfavourite.Id    = model.Id;
            editfavourite.Name  = model.Name;
            editfavourite.Image = model.Image;
            editfavourite.Icon  = model.Icon;
            var statusedit = _favouriteRepo.SaveChanges();

            if (statusedit > 0)
            {
                TempDataHelper.Put <StatusQuery>(TempData, "Notification", new StatusQuery("success", "", "Sửa thành công"));
                return(RedirectToAction("Index", "Favourite"));
            }
            return(View(editfavourite));
        }
Beispiel #30
0
        /// <summary>
        /// Starts the add process for a new categorymapping
        /// </summary>
        /// <param name="categoryId">Id of the category to add the mapping to</param>
        /// <returns>Partial view for adding the mapping</returns>
        public async Task <IActionResult> AddCategoryMapping(int categoryId)
        {
            try
            {
                var categoryModel = await _categoryService.GetCategoryByIdForCurrentUser(categoryId);

                return(PartialView("UpsertCategoryMapping", new CategoryMappingModel
                {
                    CategoryName = categoryModel.Name,
                    CategoryId = categoryModel.Id
                }));
            }
            catch (NotFoundException)
            {
                TempDataHelper.SetTemporaryMessage(TempData, MessageState.Error, Resources.CategoryNotFound);
                return(View("Index"));
            }
        }