Пример #1
0
        //Persistir e inserir um novo registro
        //Inserir Tipo de Convenio
        private bool inserir(TipoConvenio OTipoConvenio)
        {
            OTipoConvenio.setDefaultInsertValues <TipoConvenio>();

            db.TipoConvenio.Add(OTipoConvenio);

            db.SaveChanges();

            return(OTipoConvenio.id > 0);
        }
Пример #2
0
        //Realizar os tratamentos necessários
        //Salvar um novo registro
        public bool salvar(TipoConvenio OTipoConvenio)
        {
            OTipoConvenio.chaveUrl = UtilString.cleanAccents(OTipoConvenio.descricao).ToLower().Replace(" ", "-");

            if (OTipoConvenio.id == 0)
            {
                return(this.inserir(OTipoConvenio));
            }

            return(this.atualizar(OTipoConvenio));
        }
Пример #3
0
 public async Task Create(TipoConvenio model)
 {
     try
     {
         _db.TipoConvenio.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
Пример #4
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (NombreProveedor != null)
                {
                    hashCode = hashCode * 59 + NombreProveedor.GetHashCode();
                }
                if (Identificacion != null)
                {
                    hashCode = hashCode * 59 + Identificacion.GetHashCode();
                }
                if (TipoConvenio != null)
                {
                    hashCode = hashCode * 59 + TipoConvenio.GetHashCode();
                }
                if (FechaVigencia != null)
                {
                    hashCode = hashCode * 59 + FechaVigencia.GetHashCode();
                }
                if (Correo != null)
                {
                    hashCode = hashCode * 59 + Correo.GetHashCode();
                }

                /*if (Pais != null)
                 * hashCode = hashCode * 59 + Pais.GetHashCode();*/
                if (Ciudad != null)
                {
                    hashCode = hashCode * 59 + Ciudad.GetHashCode();
                }
                if (Endpoint != null)
                {
                    hashCode = hashCode * 59 + Endpoint.GetHashCode();
                }
                if (TemplateEntrada != null)
                {
                    hashCode = hashCode * 59 + TemplateEntrada.GetHashCode();
                }
                if (TemplateSalida != null)
                {
                    hashCode = hashCode * 59 + TemplateSalida.GetHashCode();
                }
                if (EstadoConvenio != null)
                {
                    hashCode = hashCode * 59 + EstadoConvenio.GetHashCode();
                }
                return(hashCode);
            }
        }
Пример #5
0
        public async Task Update(TipoConvenio model)
        {
            try
            {
                var _model = await _db.TipoConvenio.FirstOrDefaultAsync(e => e.ConvenioId == model.ConvenioId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Пример #6
0
        public async Task UpdateEstado(TipoConvenio model)
        {
            try
            {
                var _model = await _db.TipoConvenio.FirstOrDefaultAsync(e => e.ConvenioId == model.ConvenioId);

                if (_model != null)
                {
                    _model.Estado = model.Estado;

                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Пример #7
0
        //Persistir e atualizar um registro existente
        //Atualizar dados do Tipo do Convenio
        private bool atualizar(TipoConvenio OTipoConvenio)
        {
            //Localizar existentes no banco
            TipoConvenio dbTipoConvenio = this.carregar(OTipoConvenio.id);

            //Configurar valores padrão
            OTipoConvenio.setDefaultUpdateValues();

            //Atualizacao do Tipo do Convenio
            var TipoConvenioEntry = db.Entry(dbTipoConvenio);

            TipoConvenioEntry.CurrentValues.SetValues(OTipoConvenio);
            TipoConvenioEntry.ignoreFields();

            db.SaveChanges();

            return(OTipoConvenio.id > 0);
        }
Пример #8
0
                                                          public async Task <IHttpActionResult> UpdateEstado([FromBody] TipoConvenio model)
                                                          {
                                                              try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                    await _entityRepo.UpdateEstado(model);

                                                                    return(Ok()); }
                                                              catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                    return(InternalServerError(e)); }
                                                          }
Пример #9
0
                                                          public async Task <IHttpActionResult> Update([FromBody] TipoConvenio model)
                                                          {
                                                              if (!ModelState.IsValid)
                                                              {
                                                                  return(BadRequest(ModelState));
                                                              }

                                                              try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                    await _entityRepo.Update(model);

                                                                    return(Ok("Registro actualizado exitosamente!")); }
                                                              catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                    return(InternalServerError(e)); }
                                                          }
Пример #10
0
                                                          [Authorize] public async Task <IHttpActionResult> Create([FromBody] TipoConvenio model)
                                                          {
                                                              if (!ModelState.IsValid)
                                                              {
                                                                  return(BadRequest(ModelState));
                                                              }

                                                              try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                    await _entityRepo.Create(model);

                                                                    return(Ok("Registro creado exitosamente!")); }
                                                              catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                    if (e.Message.Substring(0, 44) == "An error occurred while updating the entries")
                                                                                    {
                                                                                        return(BadRequest("Ya existe un registro con ese nombre"));
                                                                                    }
                                                                                    return(InternalServerError(e)); }
                                                          }
Пример #11
0
        /// <summary>
        /// Returns true if Convenio instances are equal
        /// </summary>
        /// <param name="other">Instance of Convenio to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Convenio other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     NombreProveedor == other.NombreProveedor ||
                     NombreProveedor != null &&
                     NombreProveedor.Equals(other.NombreProveedor)
                     ) &&
                 (
                     Identificacion == other.Identificacion ||
                     Identificacion != null &&
                     Identificacion.Equals(other.Identificacion)
                 ) &&
                 (
                     TipoConvenio == other.TipoConvenio ||
                     TipoConvenio != null &&
                     TipoConvenio.Equals(other.TipoConvenio)
                 ) &&
                 (
                     FechaVigencia == other.FechaVigencia ||
                     FechaVigencia != null &&
                     FechaVigencia.Equals(other.FechaVigencia)
                 ) &&
                 (
                     Correo == other.Correo ||
                     Correo != null &&
                     Correo.Equals(other.Correo)
                 ) /*&&
                    * (
                    * Pais == other.Pais ||
                    * Pais != null &&
                    * Pais.Equals(other.Pais)
                    * ) */&&
                 (
                     Ciudad == other.Ciudad ||
                     Ciudad != null &&
                     Ciudad.Equals(other.Ciudad)
                 ) &&
                 (
                     Endpoint == other.Endpoint ||
                     Endpoint != null &&
                     Endpoint.Equals(other.Endpoint)
                 ) &&
                 (
                     TemplateEntrada == other.TemplateEntrada ||
                     TemplateEntrada != null &&
                     TemplateEntrada.Equals(other.TemplateEntrada)
                 ) &&
                 (
                     TemplateSalida == other.TemplateSalida ||
                     TemplateSalida != null &&
                     TemplateSalida.Equals(other.TemplateSalida)
                 ) &&
                 (
                     EstadoConvenio == other.EstadoConvenio ||
                     EstadoConvenio != null &&
                     EstadoConvenio.Equals(other.EstadoConvenio)
                 ));
        }