public OperationResult <Socio> UpdateSocios(Socio socioModel)
        {
            var fullname = $"{socioModel.Nombre} {socioModel.Apellido}";

            var operationResult = new OperationResult <Socio>();
            var result          = _DBContext.Socios
                                  .Find(socioModel.Id);

            result.IdSocio        = socioModel.IdSocio;
            result.Nombre         = socioModel.Nombre;
            result.Apellido       = socioModel.Apellido;
            result.NombreCompleto = fullname;
            result.Sexo           = socioModel.Sexo;
            result.Cedula         = socioModel.Cedula;
            result.Dirreccion     = socioModel.Dirreccion;
            result.Telefono       = socioModel.Telefono;
            result.Celular        = socioModel.Celular;
            result.Email          = socioModel.Email;

            try
            {
                _DBContext.Socios.Attach(result);
                _DBContext.Entry(result).State = EntityState.Modified;
                _DBContext.SaveChanges();
                operationResult = OperationResultOperation(result, true);
            }
            catch (Exception ex)
            {
                operationResult = OperationResultOperation(result, true);
            }

            return(operationResult);
        }
Esempio n. 2
0
        public OperationResult <TipoSocio> UpdateTipoSocio(TipoSocio tipoSocioModel)
        {
            var operationResult = new OperationResult <TipoSocio>();
            var result          = _DBContext.TipoSocios
                                  .Find(tipoSocioModel.IdTipoSocio);

            result.Descripcion = tipoSocioModel.Descripcion;

            try
            {
                _DBContext.TipoSocios.Attach(result);
                _DBContext.Entry(result).State = EntityState.Modified;
                _DBContext.SaveChanges();
                operationResult = OperationResultOperation(result, true);
            }
            catch (Exception ex)
            {
                operationResult = OperationResultOperation(result, true);
            }

            return(operationResult);
        }