Пример #1
0
 public List <TipoDocumentoModel> GetAll()
 {
     try
     {
         TipoDocumentoDataLayerRealm    dl     = new TipoDocumentoDataLayerRealm();
         List <TipoDocumentoModel>      list   = new List <TipoDocumentoModel>();
         List <TipoDocumentoRealmModel> models = dl.GetAll();
         foreach (TipoDocumentoRealmModel model in models)
         {
             TipoDocumentoModel realmModel = new TipoDocumentoModel();
             realmModel.Documento       = model.Documento;
             realmModel.Documento_breve = model.Documento_breve;
             realmModel.NumeroVerbali   = model.NumeroVerbali;
             realmModel.Abilitato       = model.Abilitato;
             realmModel.TipoDocumento   = model.TipoDocumento;
             list.Add(realmModel);
         }
         //list = list.OrderBy(x => x.a_descrizione).ToList();
         return(list);
     }
     catch (Exception pException)
     {
         System.Diagnostics.Debug.WriteLine("Error TipoDocumentoBusiness->GetAll " + pException.Message);
     }
     return(null);
 }
Пример #2
0
        public async Task <TipoDocumentoModel> Post(TipoDocumentoModel entity)
        {
            _context.Set <TipoDocumentoModel>().Add(entity);
            await _context.SaveChangesAsync();

            return(entity);
        }
Пример #3
0
        public async Task <TipoDocumentoModel> Put(TipoDocumentoModel entity)
        {
            _context.Set <TipoDocumentoModel>().Attach(entity);
            _context.SetEntityState(entity);
            await _context.SaveChangesAsync();

            return(entity);
        }
 // ***************************** ***************************** *****************************
 // constructor
 public TipoDocumentoAddViewModel(TipoDocumentoViewModel TipoDocumentoViewModel)
 {
     this._ParentTipoDocumento = TipoDocumentoViewModel;
     this._TipoDocumentoRepository = new GestorDocument.DAL.Repository.TipoDocumentoRepository();
     this._TipoDocumento = new TipoDocumentoModel()
     {
         IdTipoDocumento = new UNID().getNewUNID(),
         IsActive = true
     };
 }
        /// <summary>
        /// Selects the Single object of TipoDocumentoModel table.
        /// </summary>
        public TipoDocumentoModel GetTipoDocumentoModel(int aId_documento)
        {
            TipoDocumentoModel TipoDocumentoModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@pMode", 2);
                    command.Parameters.AddWithValue("@Id_documento", aId_documento);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "spTipoDocumento";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int      Id_documento        = (int)(reader["Id_documento"]);
                            string   Descripcion         = (string)(reader["Descripcion"]);
                            DateTime FECHA_CREACION      = (DateTime)(reader["FECHA_CREACION"]);
                            DateTime?FECHA_MODIFICACION  = reader["FECHA_MODIFICACION"] as DateTime?;
                            string   USUARIO_CREADOR     = (string)(reader["USUARIO_CREADOR"]);
                            string   USUARIO_MODIFICADOR = (reader["USUARIO_MODIFICADOR"]) == DBNull.Value ? null : (string)(reader["USUARIO_MODIFICADOR"]);

                            TipoDocumentoModel = new TipoDocumentoModel
                            {
                                Id_documento        = Id_documento,
                                Descripcion         = Descripcion,
                                Fecha_creacion      = FECHA_CREACION,
                                Fecha_modificacion  = FECHA_MODIFICACION,
                                Usuario_creador     = USUARIO_CREADOR,
                                Usuario_modificador = USUARIO_MODIFICADOR,
                            };
                        }
                    }
                }

                return(TipoDocumentoModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        //TODO: Debería usar la forma de trabajo de una de las soluciones abiertas para
        //TODO: crear un RestService class y su interface.
        public async Task <TipoDocumentoModel[]> GetTipoDocumentos()
        {
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(GetUrl());
            var response = await client.GetAsync(client.BaseAddress);

            response.EnsureSuccessStatusCode();
            var jsonResult = response.Content.ReadAsStringAsync().Result;

            return(TipoDocumentoModel.FromJson(jsonResult));
        }
        /// <summary>
        /// Updates a record to the TipoDocumentoModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(TipoDocumentoModel aTipoDocumentoModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@pMode", 5);
                    command.Parameters.AddWithValue("@Id_documento", aTipoDocumentoModel.Id_documento);
                    command.Parameters.AddWithValue("@Descripcion", aTipoDocumentoModel.Descripcion);
                    command.Parameters.AddWithValue("@FECHA_MODIFICACION", aTipoDocumentoModel.Fecha_modificacion == null ? (object)DBNull.Value : aTipoDocumentoModel.Fecha_modificacion);
                    command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aTipoDocumentoModel.Usuario_modificador == null ? (object)DBNull.Value : aTipoDocumentoModel.Usuario_modificador);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "spTipoDocumento";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #8
0
        /// <summary>
        /// Saves a record to the TipoDocumentoModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Insert(TipoDocumentoModel aTipoDocumentoModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@pMode", 4);
                    command.Parameters.AddWithValue("@Descripcion", aTipoDocumentoModel.Descripcion);
                    command.Parameters.AddWithValue("@FECHA_CREACION", aTipoDocumentoModel.Fecha_creacion);
                    command.Parameters.AddWithValue("@USUARIO_CREADOR", aTipoDocumentoModel.Usuario_creador);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_tTipoDocumento";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #9
0
 public bool Editar(TipoDocumentoModel aTipoDocumento)
 {
     return(ADTipoDocumentosManager.Update(aTipoDocumento));
 }
Пример #10
0
 public bool Crear(TipoDocumentoModel aTipoDocumento)
 {
     return(ADTipoDocumentosManager.Insert(aTipoDocumento));
 }
Пример #11
0
 public bool TipoDocumento_Editar(TipoDocumentoModel aTipoDocumento)
 {
     return(BLTipoDocumento.Editar(aTipoDocumento));
 }
Пример #12
0
 public bool TipoDocumento_Crear(TipoDocumentoModel aTipoDocumento)
 {
     return(BLTipoDocumento.Crear(aTipoDocumento));
 }
        public bool CanSave()
        {
            bool _CanSave = false;

            if ((!String.IsNullOrEmpty(this._TipoDocumento.TipoDocumentoName)) && (this._TipoDocumento != null))
            {
                _CanSave = true;
                this._CheckSave = this._TipoDocumentoRepository.GetTipoDocumentoAdd(this._TipoDocumento);

                if (this._CheckSave != null)
                {
                    _CanSave = false;
                    ElementExists = "El elemento ya existe.";

                }
                else
                {
                    _CanSave = true;
                    ElementExists = "";
                }
            }
            return _CanSave;
        }
 public void VerLista(DataGridView data)
 {
     Models.TipoDocumentoModel tipo = new TipoDocumentoModel();
     tipo.ListTipoDocumentPorDataGriview(data);
 }