Example #1
0
 public static ParametroVM E2VM(Model.Entities.Parametro model)
 {
     var _result = new ParametroVM
     {
         nmParametro = model.nmParametro,
         dsParametro = model.dsParametro,
         dsValor = model.dsValor
     };
     return _result;
 }
        public ActionResult Edit(ParametroVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var parametro = model.VM2E();

                    using (var db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
                            var parametroBLL = new BLL.ParametroBLL(db, _idUsuario);

                            parametroBLL.Update(parametro);
                            parametroBLL.SaveChanges();
                            trans.Complete();

                            this.AddFlashMessage(RP.Util.Resource.Message.EDIT_SUCCESS);
                            return RedirectToAction("Index");
                        }
                    }
                }
                return View(model);
            }
            catch (Exception ex)
            {
                RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                return RedirectToAction("Index", "Erro", new { area = string.Empty });
            }
        }