public ActionResult Create(FabricanteVM model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    LogBLL.Insert(new LogDado("Create", "Fabricante", _idUsuario));
                    using (var db = new Context())
                    {
                        using (var trans = new RP.DataAccess.RPTransactionScope(db))
                        {
                            var _fabricante = model.GetFabricante();

                            var _bll = new BLL.FabricanteBLL(db, _idUsuario);

                            _bll.Insert(_fabricante);
                            _bll.SaveChanges();

                            trans.Complete();

                            this.AddFlashMessage(RP.Util.Resource.Message.INSERT_SUCCESS, FlashMessage.SUCCESS);
                            return RedirectToAction("Index");
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.AddFlashMessage(RP.Util.Exception.Message.Get(ex), FlashMessage.ERROR); RP.Util.Entity.ErroLog.Add(ex, Session.SessionID, _idUsuario);
                    return RedirectToAction("Index");
                }
            }
            return View(model);
        }
示例#2
0
        public static FabricanteVM GetFabricante(Sistema.Model.Entities.Fabricante model)
        {
            var _result = new FabricanteVM
            {
                nome = model.nome,
                idFabricante = model.idFabricante,
            };

            return _result;
        }