Exemplo n.º 1
0
        public ActionResult Create(EmprestimoViewModel emprestimoViewModel)
        {
            if (ModelState.IsValid)
            {
                var emprestimoEntity = Mapper.Map <EmprestimoViewModel, Emprestimo>(emprestimoViewModel);
                emprestimoEntity.Devolvido    = false;
                emprestimoEntity.DataDevolver = CalculaDataDevolucao(emprestimoEntity);
                _wcfServiceClient.AddEmprestimo(emprestimoEntity);

                return(RedirectToAction("Index"));
            }

            emprestimoViewModel.Clientes  = GetClientesDropDownList();
            emprestimoViewModel.Materiais = GetMateraisDropDownList();
            return(View(emprestimoViewModel));
        }