Exemplo n.º 1
0
        public ActionResult SavePdv(PdvEntity pdv)
        {
            bool isSaved = false;

            DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter(User.Identity.Name);

            using (adapter)
            {
                adapter.StartTransaction(System.Data.IsolationLevel.Serializable, "SavePdv");

                PdvEntity pdv4Save;

                if (pdv.PdvId == 0)
                {
                    pdv4Save         = pdv;
                    pdv4Save.FirmaId = UserEntity.GetFirmaId(adapter, User.Identity.Name);
                }
                else
                {
                    pdv4Save = PdvEntity.FetchPdv(adapter, null, pdv.PdvId);
                    pdv4Save.UpdateDataFromOtherObject(pdv, null, null);
                }

                isSaved = adapter.SaveEntity(pdv4Save);

                adapter.Commit();
            }

            dynamic response = new { IsSaved = isSaved };

            return(CreateJsonResponse(response));
        }
Exemplo n.º 2
0
 public ActionResult GetPdv(long pdvId)
 {
     using (DataAccessAdapterBase adapter = Helper.GetDataAccessAdapter())
     {
         PdvEntity pdv = PdvEntity.FetchPdv(adapter, null, pdvId);
         return(CreateJsonResponse(pdv));
     }
 }