Ejemplo n.º 1
0
        public async Task <ActionResult> EditPaymentType(EditPaymentTypeViewModel viewModel)
        {
            var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId);

            var paymentType = project.PaymentTypes.SingleOrDefault(pt => pt.PaymentTypeId == viewModel.PaymentTypeId);

            if (paymentType == null)
            {
                return(HttpNotFound());
            }

            try
            {
                await FinanceService.EditCustomPaymentType(viewModel.ProjectId, viewModel.PaymentTypeId, viewModel.Name, viewModel.IsDefault);

                return(RedirectToAction("Setup", new { viewModel.ProjectId }));
            }
            catch (Exception exc)
            {
                ModelState.AddException(exc);
                return(View(viewModel));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> EditPaymentType(EditPaymentTypeViewModel viewModel)
        {
            var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId);

            var paymentType = project.PaymentTypes.SingleOrDefault(pt => pt.PaymentTypeId == viewModel.PaymentTypeId);
            var errorResult = AsMaster(paymentType, acl => acl.CanManageMoney);

            if (errorResult != null)
            {
                return(errorResult);
            }

            try
            {
                await FinanceService.EditCustomPaymentType(viewModel.ProjectId, CurrentUserId, viewModel.PaymentTypeId, viewModel.Name, viewModel.IsDefault);

                return(RedirectToAction("Setup", new { viewModel.ProjectId }));
            }
            catch (Exception exc)
            {
                ModelState.AddException(exc);
                return(View(viewModel));
            }
        }