public ActionResult CategoriaCreate([Bind(Include = "DESC_CATEGORIA, TAB_ORIGEM, COL_ORIGEM, STATUS")]Categoria categoria)
        {
            try
            {
                //---------------------------------------------------------------------------------------------
                //<REVER>
                //---------------------------------------------------------------------------------------------
                categoria.CREATED_DATETIME = DateTime.Now;
                categoria.CREATED_USERNAME = _controleacessoAppService.ObtainCurrentLoginFromAd();

                categoria.LAST_MODIFY_DATE = categoria.CREATED_DATETIME;
                categoria.LAST_MODIFY_USERNAME = categoria.CREATED_USERNAME;
                //---------------------------------------------------------------------------------------------

                if (ModelState.IsValid)
                {
                    _categoriaAppService.Create(categoria);
                    return RedirectToAction("CategoriaIndex");
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Erro ao salvar. Tente novamente ou, se o problema persistir, entre em contato com o suporte.");
            }

            //return View(categoria);
            CategoriaViewModel categoriaVM = new CategoriaViewModel();

            return View(categoriaVM.ToViewModel(categoria));
        }
        //
        // GET: /Categoria/CategoriaDelete/5
        public ActionResult CategoriaDelete(int ? id, bool? saveChangesError = false)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                //throw new InvalidOperationException("Something very bad happened while doing important stuff");
                throw new Exception();
            }

            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Erro na exclusão. Tente novamente ou, se o problema persistir, entre em contato com o suporte.";
            }

            var categoria = _categoriaAppService.Get(id ?? default(int));

            if (categoria == null)
            {
                //return HttpNotFound();
                throw new Exception();
            }

            CategoriaViewModel categoriaVM = new CategoriaViewModel();

            return  View(categoriaVM.ToViewModel(categoria));
        }
        public ActionResult CategoriaEditConfirmed(int? id)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                throw new Exception();
            }
            var categoriaToUpdate = _categoriaAppService.Get(id ?? default(int));

            //---------------------------------------------------------------------------------------------
            //<REVER>
            //---------------------------------------------------------------------------------------------
            categoriaToUpdate.LAST_MODIFY_DATE = DateTime.Now;
            categoriaToUpdate.LAST_MODIFY_USERNAME = _controleacessoAppService.ObtainCurrentLoginFromAd();
            //---------------------------------------------------------------------------------------------

            if (TryUpdateModel(categoriaToUpdate, "",
               new string[] { "DESC_CATEGORIA", "TAB_ORIGEM", "COL_ORIGEM", "STATUS", "LAST_MODIFY_DATE", "LAST_MODIFY_USERNAME" }))
            {
                try
                {
                    _categoriaAppService.Update(categoriaToUpdate);

                    return RedirectToAction("CategoriaIndex");
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Erro na alteração. Tente novamente ou, se o problema persistir, entre em contato com o suporte.");
                }
            }

            CategoriaViewModel categoriaVM = new CategoriaViewModel();

            return View(categoriaVM.ToViewModel(categoriaToUpdate));
        }
        // GET: /Categoria/CategoriaEdit/5
        public ActionResult CategoriaEdit(int? id)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                throw new Exception();
            }
            var categoria = _categoriaAppService.Get(id ?? default(int));
            if (categoria == null)
            {
                //return HttpNotFound();
                throw new Exception();
            }

            CategoriaViewModel categoriaVM = new CategoriaViewModel();

            return View(categoriaVM.ToViewModel(categoria));
        }