private static CreditProcess Map(EditViewModel editViewModel)
        {
            var creditProcess = new CreditProcess
                                   {
                                       CreditProcessId = editViewModel.CreditProcessId,
                                       CustomerId = editViewModel.Customer.CustomerId,
                                       UserId = editViewModel.Salesman.UserId,
                                       CreditStatusId = editViewModel.CreditStatus.CreditStatusId,
                                       Product = editViewModel.Product,
                                       //TODO: missing list of current flows with the different companies
                                   };

            return creditProcess;
        }
 public void Save(EditViewModel editViewModel, List<ProcessFlowViewModel> creditProcessFlowsList)
 {
     var creditProcess = Map(editViewModel);
     creditProcess.UpdatedAt = DateTime.Now;
     if (editViewModel.CreditProcessId.Equals(0))
     {
         creditProcess.CreatedAt = DateTime.Now;
         AddCreditProcess(creditProcess, creditProcessFlowsList);
     }
     else
     {
         UpdateCreditProcess(creditProcess, creditProcessFlowsList);
     }
 }
        public ActionResult Create()
        {
            var usersToShow = GenerateUsersToShowList(GetAvailableUsersList());
            var customersToShow = GenerateCustomersToShowList(_customersManagement.GetCustomers());
            var editViewModel = new EditViewModel
                                    {
                                        CreditProcessId = 0,
                                        Customer = new Customer(),
                                        CustomersList = customersToShow,
                                        Salesman = new User(),
                                        SalesmenList = usersToShow,
                                        CreditStatus = new CreditStatus(),
                                        CreditStatusesList = _creditStatusesManagement.GetCreditStatuses(),
                                        FinantialCompany = new Company(),
                                        FinantialCompaniesList = _companiesManagement.GetFinantialCompaniesList(),
                                        PagedItems = new List<CreditProcessXCompany>().ToPagedList(1, PageSize),
                                    };

            return View("Edit", editViewModel);
        }
        public ActionResult Edit(int id)
        {
            var creditProcess = _creditProcessesManagement.GetCreditProcess(id);
            var flowsPerCreditProcessList = _creditProcessesManagement.GetFlowsPerCreditProcess(id);
            var usersToShow = GenerateUsersToShowList(GetAvailableUsersList());
            var customersToShow = GenerateCustomersToShowList(_customersManagement.GetCustomers());
            var editViewModel = new EditViewModel
                                    {
                                        CreditProcessId = id,
                                        Customer = creditProcess.Customer,
                                        CustomersList = customersToShow,
                                        Salesman = creditProcess.User,
                                        SalesmenList = usersToShow,
                                        CreditStatus = creditProcess.CreditStatus,
                                        CreditStatusesList = _creditStatusesManagement.GetCreditStatuses(),
                                        Product = creditProcess.Product,
                                        FinantialCompany = new Company(),
                                        FinantialCompaniesList = _companiesManagement.GetFinantialCompaniesList(),
                                        PagedItems = flowsPerCreditProcessList.ToPagedList(1, PageSize),
                                    };
            var processFlowsList = flowsPerCreditProcessList.Select(Map).ToList();
            UpdateCurrentProcessFlows(creditProcess.CreditProcessId, processFlowsList);

            return View(editViewModel);
        }
 public ActionResult Save(EditViewModel editViewModel)
 {
     if (ModelState.IsValid)
     {
         //this call includes the credit flows as extra parameter
         var processFlowsList = GetCurrentProcessFlows(editViewModel.CreditProcessId);
         _creditProcessesManagement.Save(editViewModel, processFlowsList);
         ClearCurrentProcessFlows(editViewModel.CreditProcessId);
         return RedirectToAction("Index");
     }
     editViewModel.SalesmenList = GenerateUsersToShowList(GetAvailableUsersList());
     editViewModel.CustomersList = GenerateCustomersToShowList(_customersManagement.GetCustomers());
     return View("Edit", editViewModel);
 }