示例#1
0
        public CreditApplicationViewModel GetNewCreditApplicationViewModel(ClientGroup clientGroup)
        {
            var result = new CreditApplicationViewModel();

            result.ClientGroupViewModel    = new ClientGroupViewModel(clientGroup);
            result.CreditCategoryViewModel = new CreditCategoryViewModel();
            result.CreditCategoryViewModel.SelectedCreditCategoryId = Guid.Empty;
            switch (clientGroup)
            {
            case ClientGroup.PrivatePerson:
                result.CreditCategoryViewModel =
                    creditCategoryManager.GetCreditCategoryDropDownListViewModel(ClientGroup.PrivatePerson);
                break;

            case ClientGroup.SmallBusiness:
                result.CreditCategoryViewModel =
                    creditCategoryManager.GetCreditCategoryDropDownListViewModel(ClientGroup.SmallBusiness);
                break;

            case ClientGroup.CorporateClient:
                result.CreditCategoryViewModel =
                    creditCategoryManager.GetCreditCategoryDropDownListViewModel(ClientGroup.CorporateClient);
                break;

            default:
                throw new ArgumentException();
            }
            return(result);
        }
示例#2
0
 private static void FillCreditApplicationViewModel(CreditApplicationViewModel viewModel)
 {
     viewModel.RegisterDate    = DateTime.Now;
     viewModel.IsCompleted     = false;
     viewModel.CompleteDate    = null;
     viewModel.Outcome         = null;
     viewModel.RejectionReason = null;
 }
示例#3
0
 public ActionResult Create([Bind(Include = "ClientGroupViewModel,CreditCategoryViewModel,ClientId")] CreditApplicationViewModel viewModel, IEnumerable <HttpPostedFileBase> attachments)
 {
     try
     {
         if (!Request.IsAuthenticated || !User.IsInRole("Operator"))
         {
             throw new BusinessException("You don't have permissions for this operation");
         }
         creditApplicationManager.SaveNewCreditApplication(viewModel, attachments);
         return(RedirectToAction("List", "Application"));
     }
     catch (BusinessException e)
     {
         TempData["ErrorMessage"] = e.Message;
         return(RedirectToAction("Create", "Application",
                                 new { clientGroupId = (int)viewModel.ClientGroupViewModel.SelectedClientGroup }));
     }
 }
示例#4
0
        public void SaveNewCreditApplication(CreditApplicationViewModel viewModel)
        {
            Contract.NotNull(viewModel, "CreditApplicationViewModel cannot be null");
            Contract.NotNull(viewModel.ClientGroupViewModel, "ClientGroupViewModel cannot be null");
            Contract.NotNull(viewModel.CreditCategoryViewModel, "CreditCategoryViewModel  cannot be null");
            Contract.NotEmptyGuid(viewModel.CreditCategoryViewModel.SelectedCreditCategoryId, "SelectedCreditCategoryId cannot be empty");
            Contract.NotEmptyGuid(viewModel.ClientId, "ClientId cannot be empty");

            viewModel.RegisterDate    = DateTime.Now;
            viewModel.IsCompleted     = false;
            viewModel.CompleteDate    = null;
            viewModel.Outcome         = null;
            viewModel.RejectionReason = null;

            var entity = AutoMapper.Mapper.Map <CreditApplication>(viewModel);

            unitOfWork.GetRepository <CreditApplication>().InsertOrUpdate(entity);
            unitOfWork.Commit();
        }
示例#5
0
        public bool SaveNewCreditApplication(CreditApplicationViewModel viewModel)
        {
            Contract.NotNull(viewModel, "CreditApplicationViewModel cannot be null");
            Contract.NotNull(viewModel.ClientGroupViewModel, "ClientGroupViewModel cannot be null");
            Contract.NotNull(viewModel.CreditCategoryViewModel, "CreditCategoryViewModel  cannot be null");
            Contract.NotEmptyGuid(viewModel.CreditCategoryViewModel.SelectedCreditCategoryId, "SelectedCreditCategoryId cannot be empty");
            Contract.NotEmptyGuid(viewModel.ClientId, "ClientId cannot be empty");

            if (IsCreditApplicationAlreadyExistsForClient(viewModel.ClientId))
            {
                return(false);
            }

            FillCreditApplicationViewModel(viewModel);

            var entity = AutoMapper.Mapper.Map <CreditApplication>(viewModel);

            unitOfWork.GetRepository <CreditApplication>().InsertOrUpdate(entity);
            unitOfWork.Commit();

            taskManager.CreateTaskForNewCreditApplication(entity);

            return(true);
        }
示例#6
0
        public void SaveNewCreditApplication(CreditApplicationViewModel viewModel, IEnumerable <HttpPostedFileBase> attachments)
        {
            Contract.NotNull(viewModel, "CreditApplicationViewModel cannot be null");
            Contract.NotNull(viewModel.ClientGroupViewModel, "ClientGroupViewModel cannot be null");
            Contract.NotNull(viewModel.CreditCategoryViewModel, "CreditCategoryViewModel  cannot be null");
            Contract.NotEmptyGuid(viewModel.CreditCategoryViewModel.SelectedCreditCategoryId, "SelectedCreditCategoryId cannot be empty");
            Contract.NotEmptyGuid(viewModel.ClientId, "ClientId cannot be empty");

            if (IsCreditApplicationAlreadyExistsForClient(viewModel.ClientId))
            {
                throw new BusinessException("Application for this client already exists");
            }

            FillCreditApplicationViewModel(viewModel);

            var entity = AutoMapper.Mapper.Map <CreditApplication>(viewModel);

            unitOfWork.GetRepository <CreditApplication>().InsertOrUpdate(entity);
            unitOfWork.Commit();

            AddAttachments(entity.Id, attachments);

            taskManager.CreateTasksForNewCreditApplication(entity);
        }