public ActionResult Alterar(int id, Emprestimo emprestimo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    emprestimo.id = id;
                    IEmprestimoProcesso processo = EmprestimoProcesso.Instance;
                    //emprestimo.timeUpdated = DateTime.Now;
                    processo.Alterar(emprestimo);
                    processo.Confirmar();
                    // TODO: Add update logic here

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(emprestimo));
                }
            }
            catch
            {
                return(View());
            }
        }
        //
        // GET: /StatusParcela/Delete/5

        public ActionResult Excluir(int id)
        {
            if (ClasseAuxiliar.UsuarioLogado == null || (ClasseAuxiliar.DataSelecionada == default(DateTime) || ClasseAuxiliar.AreaSelecionada == null))
            {
                return(RedirectToAction("Index", "Home"));
            }
            IEmprestimoProcesso processo   = EmprestimoProcesso.Instance;
            Emprestimo          emprestimo = new Emprestimo();

            emprestimo.id  = id;
            ViewData.Model = processo.Consultar(emprestimo, SiteMVCTelerik.ModuloBasico.Enums.TipoPesquisa.E)[0];
            processo.Excluir(emprestimo);
            processo.Confirmar();
            return(RedirectToAction("EmprestimoCliente", "Emprestimo", new { id = ClasseAuxiliar.ClienteSelecionado.id }));
        }
        // [ValidateInput(false)]

        public ActionResult IncluirEmprestimoCliente(Emprestimo emprestimo, string[] dias)
        {
            try
            {
                IClienteProcesso processoCliente = ClienteProcesso.Instance;
                List <Cliente>   resultCliente   = processoCliente.ConsultarClientesDevedores();

                var resultCiente2 = (from cc in resultCliente
                                     where cc.id == ClasseAuxiliar.ClienteSelecionado.id
                                     select cc).SingleOrDefault();


                if (resultCiente2 != null && resultCiente2.id == ClasseAuxiliar.ClienteSelecionado.id)
                {
                    ModelState.AddModelError("valor", "O Cliente está com dividas em aberto.");
                }


                List <int>       diasUteis  = new List <int>();
                List <DayOfWeek> dayOfWeeks = new List <DayOfWeek>();
                if (dias != null)
                {
                    for (int i = 0; i < dias.Length; i++)
                    {
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Friday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Friday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Monday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Monday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Saturday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Saturday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Sunday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Sunday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Thursday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Thursday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Tuesday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Tuesday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Wednesday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Wednesday);
                        }


                        diasUteis.Add(Convert.ToInt16(dias[i]));
                    }
                }


                ViewData["DiasUteis"] = ClasseAuxiliar.CarregarCheckBoxEnum <DiasUteis>(diasUteis);

                var teste = Request;
                IEmprestimoProcesso processo = EmprestimoProcesso.Instance;
                //if (ModelState.IsValid)
                {
                    emprestimo.cliente_id = ClasseAuxiliar.ClienteSelecionado.id;
                    emprestimo.usuario_id = ClasseAuxiliar.UsuarioLogado.id;
                    emprestimo.area_id    = ClasseAuxiliar.AreaSelecionada.id;
                    //emprestimo.timeCreated = DateTime.Now;
                    //emprestimo.timeUpdated = DateTime.Now;
                    processo.Incluir(emprestimo, dayOfWeeks);
                    processo.Confirmar();
                    return(RedirectToAction("EmprestimoCliente", new { id = ClasseAuxiliar.ClienteSelecionado.id }));
                }
                //else
                //{
                //    return View(emprestimo);
                //}
            }
            catch (Exception e)
            {
                return(View(emprestimo));
            }
        }
        public ActionResult Incluir(Emprestimo emprestimo, string[] dias)
        {
            try
            {
                IClienteProcesso processoCliente = ClienteProcesso.Instance;
                List <Cliente>   resultCliente   = processoCliente.ConsultarClientesDevedores();

                var resultCiente2 = from cc in resultCliente
                                    where cc.ID == ClasseAuxiliar.ClienteSelecionado.ID
                                    select cc;


                if (resultCliente.Count > 0)
                {
                    ModelState.AddModelError("valor", "O Cliente está com dividas em aberto.");
                }

                List <int>       diasUteis  = new List <int>();
                List <DayOfWeek> dayOfWeeks = new List <DayOfWeek>();
                if (dias != null)
                {
                    for (int i = 0; i < dias.Length; i++)
                    {
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Friday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Friday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Monday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Monday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Saturday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Saturday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Sunday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Sunday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Thursday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Thursday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Tuesday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Tuesday);
                        }
                        if (Convert.ToInt16(dias[i]) == (int)DayOfWeek.Wednesday)
                        {
                            dayOfWeeks.Add(DayOfWeek.Wednesday);
                        }


                        diasUteis.Add(Convert.ToInt16(dias[i]));
                    }
                }

                ViewData["DiasUteis"] = ClasseAuxiliar.CarregarCheckBoxEnum <DiasUteis>(diasUteis);
                if (ModelState.IsValid)
                {
                    IEmprestimoProcesso processo = EmprestimoProcesso.Instance;
                    emprestimo.area_id         = ClasseAuxiliar.AreaSelecionada.ID;
                    emprestimo.usuario_id      = ClasseAuxiliar.UsuarioLogado.ID;
                    emprestimo.data_emprestimo = ClasseAuxiliar.DataSelecionada;
                    emprestimo.timeCreated     = DateTime.Now;
                    processo.Incluir(emprestimo, dayOfWeeks);
                    processo.Confirmar();
                    return(RedirectToAction("IncluirPrestacaoConta", "Movimentacao"));
                }
                else
                {
                    return(View(emprestimo));
                }
            }
            catch (Exception e)
            {
                return(View(emprestimo));
            }
        }