Beispiel #1
0
        private void PopulateGrid(int id = -1)
        {
            mdc = new ModelDataContext();
            try
            {
                var sourceNota = from nota in mdc.Notas
                                 join alu in mdc.Aluno on nota.idAluno equals alu.idAluno
                                 where nota.idTurma == id
                                 select new { alu.Nome, nota.a1, nota.a2, nota.a3, nota.media };



                gwNotas.DataSource = sourceNota;

                gwNotas.DataBind();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #2
0
        public static RideDto GetRideDto(ModelDataContext context, int rideId, int?userId)
        {
            var ride = context.Rides
                       .Where(row => row.RideId == rideId)
                       .Where(row => userId == null || row.UserId == userId)
                       .Select(row => new RideDto {
                RideId              = row.RideId,
                StartUtc            = row.StartUtc,
                EndUtc              = row.EndUtc,
                Name                = row.Name,
                AverageSpeedMph     = row.AverageSpeedMph,
                MaxSpeedMph         = row.MaxSpeedMph,
                DistanceMiles       = row.DistanceMiles,
                UserId              = row.UserId,
                UserName            = row.User.Name,
                UserProfileImageUrl = row.User.ProfileImageUrl,
            })
                       .SingleOrDefault();

            if (ride == null)
            {
                return(null);
            }

            ride.Jumps         = GetJumps(context, rideId);
            ride.Locations     = GetLocations(context, rideId);
            ride.TrailAttempts = GetTrailAttempts(context, rideId);
            ride.Achievements  = GetAchievements(context, rideId);

            return(ride);
        }
Beispiel #3
0
        /// <summary>
        /// Perform the query
        /// </summary>
        protected IQueryable <TDomain> QueryInternal(ModelDataContext context, Expression <Func <TModel, bool> > query)
        {
            var domainQuery = m_mapper.MapModelExpression <TModel, TDomain>(query);

            this.m_tracer.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 0, "LINQ2SQL: {0}", domainQuery);
            return(context.GetTable <TDomain>().Where(domainQuery));
        }
Beispiel #4
0
        public List <Artista> ObtenerArtistaGenero(int idGenero, bool insertarSeleccion)
        {
            List <Artista>   result;
            ModelDataContext db = new ModelDataContext();

            try
            {
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                result = db.Artista.Where(w => w.IdGenero == idGenero).OrderBy(o => o.Descripcion).ToList();;
                if (insertarSeleccion)
                {
                    result.Insert(0,
                                  new Artista
                    {
                        Id          = BusinessVariables.ComboBoxCatalogo.ValueSeleccione,
                        Descripcion = BusinessVariables.ComboBoxCatalogo.DescripcionSeleccione
                    });
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
            return(result);
        }
        /// <summary>
        /// Perform the actual update.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="data">Data.</param>
        public override TModel Update(ModelDataContext context, TModel data, IPrincipal principal)
        {
            // Check for key
            if (data.Key == Guid.Empty)
            {
                throw new SqlFormalConstraintException(SqlFormalConstraintType.NonIdentityUpdate);
            }

            // Get current object
            var domainObject  = this.FromModelInstance(data, context, principal) as TDomain;
            var currentObject = context.GetTable <TDomain>().FirstOrDefault(ExpressionRewriter.Rewrite <TDomain>(o => o.Id == data.Key));

            // Not found
            if (currentObject == null)
            {
                throw new KeyNotFoundException(data.Key.ToString());
            }

            // VObject
            var vobject = domainObject as IDbNonVersionedBaseData;

            if (vobject != null)
            {
                vobject.UpdatedBy   = principal.GetUser(context).UserId;
                vobject.UpdatedTime = DateTimeOffset.Now;
            }

            currentObject.CopyObjectData(domainObject);
            context.SubmitChanges();

            return(this.ToModelInstance(domainObject, context, principal));
        }
        private void populateFields(int pGetID = 0)
        {
            mdc = new ModelDataContext();
            try
            {
                if (pGetID > 0)
                {
                    Materia materia = mdc.Materia.First(mat => mat.idMateria == pGetID);

                    tbCodigo.Text    = pGetID.ToString();
                    tbNome.Text      = materia.Nomem.Trim();
                    tbDescricao.Text = materia.Descricao.Trim();
                }
                else
                {
                    Response.Redirect("Materias.aspx");
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #7
0
        public void GeneraSolicitudCancion(int idUsuario, string idGenero, string idArtista, string idAlbum, string cancion, string comentarios)
        {
            ModelDataContext db = new ModelDataContext();

            try
            {
                Sugerencia sugerencia = new Sugerencia
                {
                    IdUsuario   = idUsuario,
                    Genero      = idGenero.Trim().ToUpper(),
                    Artista     = idArtista.Trim().ToUpper(),
                    Album       = idAlbum.Trim().ToUpper(),
                    Cancion     = cancion.Trim().ToUpper(),
                    Comentarios = comentarios.Trim().ToUpper()
                };
                db.Sugerencia.AddObject(sugerencia);
                db.SaveChanges();
                BusinessCorreo.SendMail("*****@*****.**", "Solicitud de Cancion", string.Format("Genero: {0}\nArtista: {1}\nAlbum: {2}\nCanción: {3}\n Comentarios: {4}", sugerencia.Genero, sugerencia.Artista, sugerencia.Album, sugerencia.Cancion, sugerencia.Comentarios));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Beispiel #8
0
        public void CrearCancion(int idAlbum, string nombreArchivo)
        {
            ModelDataContext db = new ModelDataContext();

            try
            {
                Cancion  newSong  = new Cancion();
                FileInfo fileInfo = new FileInfo(BusinessVariables.Directorios.RepositorioTemporal + nombreArchivo);
                BusinessFile.MoverTemporales(BusinessVariables.Directorios.RepositorioTemporal, BusinessVariables.Directorios.Repositorio, nombreArchivo);
                switch (fileInfo.Extension.ToLower())
                {
                case ".mp3":
                    newSong = new Cancion
                    {
                        IdAlbum     = idAlbum,
                        Descripcion = nombreArchivo,
                        Extension   = fileInfo.Extension,
                        ContentType = "audio/mpeg3",
                        FilePath    = BusinessVariables.Directorios.Repositorio + nombreArchivo,
                        Data        = null
                    };
                    break;

                case ".m4a":
                    newSong = new Cancion
                    {
                        IdAlbum     = idAlbum,
                        Descripcion = nombreArchivo,
                        Extension   = fileInfo.Extension,
                        ContentType = "audio/mpeg4",
                        FilePath    = BusinessVariables.Directorios.Repositorio + nombreArchivo,
                        Data        = null
                    };
                    break;

                case ".m4b":
                    newSong = new Cancion
                    {
                        IdAlbum     = idAlbum,
                        Descripcion = nombreArchivo,
                        Extension   = fileInfo.Extension,
                        ContentType = "audio/mpeg4",
                        FilePath    = BusinessVariables.Directorios.Repositorio + nombreArchivo,
                        Data        = null
                    };
                    break;
                }
                db.Cancion.AddObject(newSong);
                db.SaveChanges();
                BusinessFile.LimpiarTemporales(nombreArchivo);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
        }
        private void PopulateFields(int pGetID = 0)
        {
            mdc = new ModelDataContext();
            try
            {
                if (pGetID > 0)
                {
                    Model.Turma turma = mdc.Turma.First(tur => tur.idTurma == pGetID);

                    tbCodTurma.Text   = pGetID.ToString();
                    tbCodMateria.Text = turma.idMateria.ToString().Trim();
                    tbNome.Text       = turma.Nome.Trim();
                }
                else
                {
                    Response.Redirect("Turma.aspx");
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #10
0
        public void Analyse(ModelDataContext context, int userId, int rideId)
        {
            var distanceAchievements = context.DistanceAchievements
                                       .Select(row => new MinDistanceAchievement {
                DistanceAchievementId = row.DistanceAchievementId,
                MinDistanceMiles      = row.MinDistanceMiles,
                Name = row.Name,
            })
                                       .ToList();

            double distance = context.Rides
                              .Where(row => row.RideId == rideId)
                              .Select(row => row.DistanceMiles)
                              .SingleOrDefault();

            foreach (var distanceAchievement in distanceAchievements)
            {
                if (distanceAchievement.Check(distance))
                {
                    UserDistanceAchievement userDistanceAchievement = new UserDistanceAchievement {
                        RideId = rideId,
                        DistanceAchievementId = distanceAchievement.DistanceAchievementId,
                        UserId = userId,
                    };

                    context.UserDistanceAchievements.Add(userDistanceAchievement);
                    context.SaveChanges();
                }
            }
        }
Beispiel #11
0
        public void GeneraVisita(string ip)
        {
            if (ip.Trim() == string.Empty)
            {
                return;
            }
            ModelDataContext db = new ModelDataContext();

            try
            {
                Visita visita = db.Visita.SingleOrDefault(s => s.Ip == ip);
                if (visita == null)
                {
                    visita = new Visita {
                        Ip = ip, Veces = 1
                    };
                    db.Visita.AddObject(visita);
                }
                else
                {
                    visita.Veces += 1;
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Beispiel #12
0
        /// <summary>
        /// Insert the specified TModel into the database
        /// </summary>
        public override TModel Insert(ModelDataContext context, TModel data, IPrincipal principal)
        {
            var inserted = this.m_actPersister.Insert(context, data, principal);

            data.Key = inserted.Key;
            return(base.Insert(context, data, principal));
        }
Beispiel #13
0
    public string Verify(String id)
    {
        try
        {
            ModelDataContext db = new ModelDataContext();
            var query           = from p in db.UserInformations where p.GUID == id select p;

            foreach (UserInformation p in query)
            {
                /*UserInformation info = new UserInformation();
                 * info.FirstName = p.FirstName;
                 * info.LastName = p.LastName;
                 * info.Address = p.Address;
                 * info.Phone = p.Phone;
                 * info.PostalCode = p.PostalCode;
                 * info.Email = p.Email;
                 * info.Username = p.Username;
                 * info.Password=p.Password;*/
                p.IsVerified = true;
            }


            db.SubmitChanges();
            return("verified.");
        }
        catch (Exception e)
        {
            return("Error: " + e);
        }
    }
Beispiel #14
0
        public ListaReproduccion ObtenerListaReproduccionById(int idLista)
        {
            ListaReproduccion result = null;
            ModelDataContext  db     = new ModelDataContext();

            try
            {
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                result = db.ListaReproduccion.SingleOrDefault(w => w.Id == idLista);
                db.LoadProperty(result, "ListaReproduccionDetalle");
                foreach (ListaReproduccionDetalle detalle in result.ListaReproduccionDetalle)
                {
                    db.LoadProperty(detalle, "Cancion");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
            return(result);
        }
Beispiel #15
0
        private void onInsert()
        {
            mdc = new ModelDataContext();
            try
            {
                Loja loja = new Loja();
                loja.IdLoja       = int.Parse(tbIdLoja.Text.Trim());
                loja.Loja1        = tbLoja.Text.Trim();
                loja.DataCadastro = DateTime.Parse(lblDataCadastro.Text.Trim());
                loja.Endereco     = tbEndereco.Text.Trim();
                loja.Celular      = tbTelefone.Text.Trim();
                loja.Cep          = tbCep.Text.Trim();
                loja.Cidade       = tbCidade.Text.Trim();
                loja.Municipio    = tbMunicipio.Text.Trim();
                loja.UF           = tbUF.Value.ToString();

                mdc.Lojas.InsertOnSubmit(loja);
                mdc.SubmitChanges();

                Response.Write("<script language=javascript>alert('Cadastro efetuado com sucesso!!!');window.location.href='Loja_Add.aspx';</script>");
            }
            catch (Exception)


            {
                Response.Write("<script language=javascript>alert('Cadastro Existente !!!');window.location.href='Loja_Add.aspx';</script>");
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #16
0
    public void InsertUserInformation(UserInformation info)
    {
        ModelDataContext db = new ModelDataContext();

        db.UserInformations.InsertOnSubmit(info);
        db.SubmitChanges();
    }
    public string UpdateOrder(int id, Order order)
    {
        try
        {
            ModelDataContext db = new ModelDataContext();
            var query           = from p in db.Orders where p.ID == id select p;

            foreach (Order p in query)
            {
                p.ClientID      = order.ClientID;
                p.ProductID     = order.ProductID;
                p.OrderQuantity = order.OrderQuantity;
                p.OrderDate     = order.OrderDate;
                p.IsInCart      = order.IsInCart;
            }


            db.SubmitChanges();
            return(order.OrderDate + " updated successfully.");
        }
        catch (Exception e)
        {
            return("Error: " + e);
        }
    }
Beispiel #18
0
 public MeasuresController(ModelDataContext modelDB, IConfiguration config, IServiceProvider serviceProvider, ILogger <MeasuresController> logger)
 {
     _modelDB     = modelDB;
     _config      = config;
     _fileService = (IFileService)serviceProvider.GetRequiredService(Type.GetType(config["Files:Type"]));
     _logger      = logger;
 }
        private void populateFields(int pGetID = 0)
        {
            mdc = new ModelDataContext();
            try
            {
                if (pGetID > 0)
                {
                    Model.Curso curso = mdc.Curso.First(cur => cur.idCurso == pGetID);

                    tbCodCurso.Text  = pGetID.ToString();
                    tbNome.Text      = curso.Nome.Trim();
                    tbDescricao.Text = curso.Descricao.Trim();
                }
                else
                {
                    Response.Redirect("Materias.aspx");
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #20
0
        private void OnUpdate()
        {
            mdc = new ModelDataContext();
            try
            {
                Model.Aluno aluno = mdc.Aluno.First(alu => alu.idAluno == int.Parse(tbCodAluno.Text.Trim()));
                aluno.Nome            = tbNome.Text.Trim();
                aluno.Endereco        = tbEndereco.Text.Trim();
                aluno.Cep             = tbCep.Text.Trim();
                aluno.Telefone        = tbTelefone.Text.Trim();
                aluno.Celular         = tbCelular.Text.Trim();
                aluno.dataNascimento  = DateTime.Parse(tbDataNasc.Text.Trim());
                aluno.dataAtualizacao = DateTime.Parse(DateTime.Now.ToShortDateString());

                mdc.SubmitChanges();
                Response.Redirect("Aluno.aspx");
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #21
0
        private void Initialize()
        {
            if (_result == null)
            {
                var item = (IMenuDocItem)this.Document.ProjectItem;
                _result = (IExperimentResultItem)item.Arguments[0];
            }

            if (_result == null)
            {
                return;
            }

            _modelContext = this._result.GetCtx <ModelDataContext>();
            _resultCtx    = _result.GetCtx <ResultDataContext>();

            _stdStepInfos = new Dictionary <string, StdStep>();

            _datas         = new Dictionary <string, ResultData>();
            _eaInfos       = new Dictionary <string, List <EAItem> >();
            _maMatchInfos  = new Dictionary <string, List <MAItem> >();
            _eaMatchInfos  = new Dictionary <string, List <EAItem> >();
            _eamMatchInfos = new Dictionary <string, List <EAItem> >();

            ImportData_StdStep();
            ImportData();

            //this.gridView1.OptionsBehavior.Editable = false;
        }
        private void OnInsert()
        {
            mdc = new ModelDataContext();
            try
            {
                Model.Turma turma = new Model.Turma();

                turma.idMateria    = int.Parse(tbCodMaterias.Text.Trim());
                turma.Nome         = tbNome.Text.Trim();
                turma.dataCadastro = Convert.ToDateTime(tbDataCadastro.Text.Trim());

                mdc.Turma.InsertOnSubmit(turma);
                mdc.SubmitChanges();

                Response.Redirect("Turma.aspx");
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #23
0
        public void AddCustomerTest()
        {
            using (var dataContext = new ModelDataContext())
                using (var unitOfWork = new UnitOfWork(dataContext))
                {
                    var customerID = Guid.NewGuid();

                    var customer = new Customer()
                    {
                        ID         = Guid.NewGuid(),
                        Name       = "BBC",
                        Address    = "No.1 Bee Street",
                        City       = "London",
                        Country    = "UK",
                        Region     = "AA",
                        Fax        = "000000",
                        Phone      = "00000000000",
                        PostalCode = "555555"
                    };

                    var customerRepository = unitOfWork.Repository <Customer>();

                    customerRepository.Insert(customer);;
                    unitOfWork.SaveChanges();

                    var insertedCustomer = customerRepository.Find(customerID);

                    Assert.IsNotNull(insertedCustomer);
                    Assert.AreEqual(customerID, insertedCustomer.ID);
                }
        }
Beispiel #24
0
        public Usuario GetUserDataAutenticateId(int idUsuario, string ip)
        {
            Usuario          result;
            ModelDataContext db = new ModelDataContext();

            try
            {
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                result = db.Usuario.SingleOrDefault(w => w.Id == idUsuario && w.Activo && w.Habilitado);
                if (result != null)
                {
                    BitacoraAcceso nuevoAcceso = new BitacoraAcceso
                    {
                        IdUsuario = result.Id,
                        Fecha     = DateTime.Now,
                        Ip        = ip
                    };

                    db.BitacoraAcceso.AddObject(nuevoAcceso);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
            return(result);
        }
Beispiel #25
0
        public List <TipoIncidencia> ObtenerTodos(bool insertarSeleccion)
        {
            List <TipoIncidencia> result;
            ModelDataContext      db = new ModelDataContext();

            try
            {
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                result = db.TipoIncidencia.OrderBy(o => o.Descripcion).ToList();;
                if (insertarSeleccion)
                {
                    result.Insert(0,
                                  new TipoIncidencia
                    {
                        Id          = BusinessVariables.ComboBoxCatalogo.ValueSeleccione,
                        Descripcion = BusinessVariables.ComboBoxCatalogo.DescripcionSeleccione
                    });
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                db.Dispose();
            }
            return(result);
        }
Beispiel #26
0
        /// <summary>
        /// Delete the specified identity
        /// </summary>
        public void DeleteIdentity(string userName, IPrincipal authContext)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException(nameof(userName));
            }

            this.m_traceSource.TraceInformation("Delete identity {0}", userName);
            try
            {
                // submit the changes
                using (var dataContext = new ModelDataContext(this.m_configuration.ReadWriteConnectionString))
                {
                    new PolicyPermission(System.Security.Permissions.PermissionState.Unrestricted, PermissionPolicyIdentifiers.UnrestrictedAdministration, authContext).Demand();

                    var user = dataContext.SecurityUsers.FirstOrDefault(o => o.UserName == userName);
                    if (user == null)
                    {
                        throw new KeyNotFoundException("Specified user does not exist!");
                    }

                    // Obsolete
                    user.ObsoletionTime    = DateTimeOffset.Now;
                    user.ObsoletedByEntity = authContext.GetUser(dataContext);
                    user.SecurityStamp     = Guid.NewGuid().ToString();

                    dataContext.SubmitChanges();
                }
            }
            catch (Exception e)
            {
                this.m_traceSource.TraceEvent(TraceEventType.Error, e.HResult, e.ToString());
                throw;
            }
        }
Beispiel #27
0
 /// <summary>
 /// Update the specified user entity
 /// </summary>
 public override Core.Model.Entities.UserEntity Update(ModelDataContext context, Core.Model.Entities.UserEntity data, IPrincipal principal)
 {
     data.SecurityUser?.EnsureExists(context, principal);
     data.SecurityUserKey = data.SecurityUser?.Key ?? data.SecurityUserKey;
     this.m_personPersister.Update(context, data, principal);
     return(base.Insert(context, data, principal));
 }
Beispiel #28
0
        private void OnInsert()
        {
            mdc = new ModelDataContext();
            try
            {
                Materia materia = new Materia();


                materia.Nome         = tbNome.Text.Trim();
                materia.Descricao    = tbDescriao.Text.Trim();
                materia.dataCadastro = Convert.ToDateTime(tbDataCadastro.Text.Trim());

                mdc.Materia.InsertOnSubmit(materia);
                mdc.SubmitChanges();

                Response.Redirect("Materias.aspx");
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #29
0
        /// <summary>
        /// Update the roles to security user
        /// </summary>
        public override Core.Model.Security.SecurityApplication Update(ModelDataContext context, Core.Model.Security.SecurityApplication data, IPrincipal principal)
        {
            var domainInstance = this.FromModelInstance(data, context, principal) as Data.SecurityApplication;

            var currentObject = context.GetTable <Data.SecurityApplication>().FirstOrDefault(ExpressionRewriter.Rewrite <Data.SecurityApplication>(o => o.Id == data.Key));

            if (currentObject == null)
            {
                throw new KeyNotFoundException(data.Key.ToString());
            }

            currentObject.CopyObjectData(domainInstance);

            currentObject.ObsoletedBy    = data.ObsoletedByKey == Guid.Empty ? null : data.ObsoletedByKey;
            currentObject.ObsoletionTime = data.ObsoletionTime;

            context.SubmitChanges();

            context.SecurityApplicationPolicies.DeleteAllOnSubmit(context.SecurityApplicationPolicies.Where(o => o.ApplicationId == domainInstance.Id));

            context.SubmitChanges();

            context.SecurityApplicationPolicies.InsertAllOnSubmit(data.Policies.Select(o => new Data.SecurityApplicationPolicy
            {
                PolicyId                 = o.PolicyKey.Value,
                PolicyAction             = (int)o.GrantType,
                ApplicationId            = domainInstance.Id,
                SecurityPolicyInstanceId = Guid.NewGuid()
            }));

            context.SubmitChanges();

            return(data);
        }
Beispiel #30
0
        private void populateFields(int pGetID = 0)
        {
            mdc = new ModelDataContext();
            try
            {
                if (pGetID > 0)
                {
                    Model.Aluno aluno = mdc.Aluno.First(alu => alu.idAluno == pGetID);

                    tbCodAluno.Text = pGetID.ToString();
                    tbNome.Text     = aluno.Nome.Trim();
                    tbEndereco.Text = aluno.Endereco.Trim();
                    tbCep.Text      = aluno.Cep.Trim();
                    tbTelefone.Text = aluno.Telefone.Trim();
                    tbCelular.Text  = aluno.Celular.Trim();
                    tbDataNasc.Text = aluno.dataNascimento.ToString();
                }
                else
                {
                    Response.Redirect("Aluno.aspx");
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                mdc.Dispose();
            }
        }
Beispiel #31
0
 public List<T_Model> GetModelByID(long ID)
 {
     ModelDataContext db1 = new ModelDataContext(Shove._Web.WebConfig.GetAppSettingsString("ConnectionString"));
     var Model = from s in db1.T_Model
                 where s.id.Equals(ID)
                 select s;
     return Model.ToList<T_Model>();
 }
Beispiel #32
0
 public List<T_Model> GetModel(long UserID, string PlayType, string TypeName)
 {
     ModelDataContext db1 = new ModelDataContext(Shove._Web.WebConfig.GetAppSettingsString("ConnectionString"));
     var Model = from s in db1.T_Model
                 where s.UserID.Equals(UserID) && s.PlayTypeID.Equals(PlayType) && s.TypeName.Equals(TypeName)
                    select s;
     return Model.ToList<T_Model>();
 }
 public User GetUserByUsername(String username)
 {
     var db = new ModelDataContext(connectionString);
     var user = from u in db.Users
                where u.username == username
                select u;
     return user.FirstOrDefault<User>();
 }
 public Boolean ValidCredentials(String username, String password)
 {
     var db = new ModelDataContext(connectionString);
     var users = from u in db.Users
                 where u.username == username && u.password == password
                 select u;
     int rows = users.Count<User>();
     return rows > 0;
 }
    public bool removeByUserId(string question, string vacancyNumber)
    {
        try
        {
            var obj = (from p in ctx.VacancyKillerQuestions
                       where p.question == @question && p.vacancyNumber == @vacancyNumber
                       select p).Single();

            model.VacancyKillerQuestion accObj = (VacancyKillerQuestion)obj;

            ctx.VacancyKillerQuestions.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool presist(ApplicationDTO entity)
    {
        try
        {
            model.Application obj = new Application();
            obj.userName = entity.userName;
            obj.vacancyNumber = entity.vacancyNumber;
            obj.status = entity.status;

            ctx.Applications.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool removeByUserId(string userName, string vacancyNumber)
    {
        try
        {
            var obj = (from p in ctx.Applications
                       where p.userName == @userName && p.vacancyNumber == @vacancyNumber
                       select p).Single();

            Application accObj = (Application)obj;

            ctx.Applications.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
Beispiel #38
0
        protected void SignUp_Click(object sender, EventArgs e)
        {
            try
            {
                Datamanager dtm = new Datamanager();
                ModelDataContext mod = new ModelDataContext();

                UvaRequest uvReq = new UvaRequest();
                string userUvaId = uvReq.GetUvaUserIdByUsername(txt_uvauser.Text);
                if (userUvaId != null && !userUvaId.Equals("0") && !userUvaId.Equals(""))
                {
                    MembershipUser user =
                    Membership.CreateUser(txt_uvauser.Text, txt_password.Text, txt_email.Text);

                    Guid id = (Guid)user.ProviderUserKey;

                    int intUserUvaId = int.Parse(userUvaId);

                    Usuario us = new Usuario()
                    {
                        Nombre = txt_name.Text,
                        IdUser = id,
                        Universidad = txt_uni.Text,
                        Uname = txt_uvauser.Text,
                        Uid = intUserUvaId

                    };

                    mod.Usuarios.InsertOnSubmit(us);
                    mod.SubmitChanges();
                    //FormsAuthentication.SetAuthCookie(txt_name.Text, false);

                    Response.Redirect("Login.aspx");
                }
                else
                {
                    if (userUvaId.Equals("")) Msg.Text = "Hubo un problema con el servidor de uHunt intenta el registro más tarde.";
                    if (userUvaId == null||userUvaId.Equals("0")) Msg.Text = "Usuario de Uva no esta registrado";
                }

            }
            catch (System.Web.Security.MembershipCreateUserException ex)
            {
                switch (ex.StatusCode)
                {
                    case MembershipCreateStatus.DuplicateEmail:
                        Msg.Text = "Email está en uso";
                        break;
                    case MembershipCreateStatus.DuplicateProviderUserKey:
                        Msg.Text = "DPUK";
                        break;
                    case MembershipCreateStatus.DuplicateUserName:
                        Msg.Text = "Usuario está en uso";
                        break;
                    case MembershipCreateStatus.InvalidAnswer:
                        Msg.Text = "Respuesta Invalida";
                        break;
                    case MembershipCreateStatus.InvalidEmail:
                        Msg.Text = "Email inválido";
                        break;
                    case MembershipCreateStatus.InvalidPassword:
                        Msg.Text = "Contraseña inválida";
                        break;
                    case MembershipCreateStatus.InvalidProviderUserKey:
                        Msg.Text = "Invalid Provider User Key";
                        break;
                    case MembershipCreateStatus.InvalidQuestion:
                        Msg.Text = "Invalid Question";
                        break;
                    case MembershipCreateStatus.InvalidUserName:
                        Msg.Text = "Usuario Inválido";
                        break;
                    case MembershipCreateStatus.ProviderError:
                        Msg.Text = "Provider Error";
                        break;
                    case MembershipCreateStatus.Success:
                        Msg.Text = "Succes!";
                        break;
                    case MembershipCreateStatus.UserRejected:
                        Msg.Text = "User Rejected";
                        break;
                    default:
                        break;
                }
            }
            //MembershipUser current =
            //    Membership.GetUser();

            //if (current != null)
            //{

            //}

            //TODO: Crear usuario en la otra tabla
        }
 public static ModelDataContext getModelInstance()
 {
     if (modelCtx == null)
         modelCtx = new ModelDataContext();
     return modelCtx;
 }
 public ApplicationDAO()
 {
     ctx =  new ModelDataContext();//ModelFactory.getModelInstance();
 }
    public bool merge(ApplicationDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.Applications
                       where p.userName == @entity.userName && p.vacancyNumber == @entity.vacancyNumber
                       select p).Single();

            model.Application obj = (Application)addObj;

            /*Update*/
            obj.userName = entity.userName;
            obj.vacancyNumber = entity.vacancyNumber;
            obj.status = entity.status;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "Application Merge: " + " [" + entity.userName + " , " + entity.vacancyNumber + "] " + e.Message;

            ctx.Dispose();
            ctx = new ModelDataContext();
            ctx.SubmitChanges();

            return false;
        }
    }
    public bool presist(SupportDocDTO entity)
    {
        try
        {
            model.supportDoc obj = new supportDoc();
            obj.userName = entity.userName;
            obj.title = entity.title;
            obj.description = entity.description;
            obj.content = new System.Data.Linq.Binary(entity.content);//Array of bytes to Linq.Binary

            ctx.supportDocs.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
 public UserRepository()
 {
     db = new ModelDataContext(connectionString);
 }
    public bool removeByUserId(string userName, string title)
    {
        try
        {
            var obj = (from p in ctx.supportDocs
                       where p.userName == @userName && p.title == @title
                       select p).Single();

            model.supportDoc accObj = (supportDoc)obj;

            ctx.supportDocs.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
 public SupportDocDAO()
 {
     ctx =  new ModelDataContext();//ModelFactory.getModelInstance();
 }
    public bool merge(SupportDocDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.supportDocs
                       where p.userName == @entity.userName && p.title == @entity.title
                       select p).Single();

            model.supportDoc obj = (supportDoc)addObj;

            /*Update*/
            obj.userName = entity.userName;
            obj.title = entity.title;
            obj.description = entity.description;
            obj.content = new System.Data.Linq.Binary(entity.content);//Array of bytes to Linq.Binary

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "supportDoc Merge: " + " ["+entity.userName+" , "+entity.title+"] " + e.Message;
            ctx.SubmitChanges();

            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool merge(BasicEduSubjectDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.BasicEduSubjects
                       where p.userName == @entity.userName && p.subjectName == @entity.subjectName
                       select p).Single();

            model.BasicEduSubject obj = (BasicEduSubject)addObj;

            /*Update*/
            obj.userName = entity.userName;
            obj.subjectName = entity.subjectName;
            obj.subjectDescription = entity.subjectDescription;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "BasicEduSubject Merge: " + " ["+entity.userName+" , "+entity.subjectName+"] " + e.Message;

            ctx.Dispose();
            ctx = new ModelDataContext();
            ctx.SubmitChanges();

            return false;
        }
    }
    public bool removeByUserId(string userName, string subjectName)
    {
        try
        {
            var obj = (from p in ctx.BasicEduSubjects
                       where p.userName == @userName && p.subjectName == @subjectName
                       select p).Single();

            BasicEduSubject accObj = (BasicEduSubject)obj;

            ctx.BasicEduSubjects.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool presist(VacancyKillerQuestionDTO entity)
    {
        try
        {
            model.VacancyKillerQuestion obj = new VacancyKillerQuestion();
            obj.question = entity.question;
            obj.vacancyNumber = entity.vacancyNumber;
            obj.answer = entity.answer;

            ctx.VacancyKillerQuestions.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool merge(VacancyKillerQuestionDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.VacancyKillerQuestions
                       where p.question == @entity.question && p.vacancyNumber == @entity.vacancyNumber
                       select p).Single();

            model.VacancyKillerQuestion obj = (VacancyKillerQuestion)addObj;

            /*Update*/
            obj.question = entity.question;
            obj.vacancyNumber = entity.vacancyNumber;
            obj.answer = entity.answer;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "VacancyKillerQuestion Merge: " + " [" + entity.question + " , " + entity.vacancyNumber + "] " + e.Message;
            ctx.SubmitChanges();

            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
 public VacancyKillerQuestionDAO()
 {
     ctx =  new ModelDataContext();//ModelFactory.getModelInstance();
 }
Beispiel #52
0
 public Datamanager()
 {
     modx = new ModelDataContext();
     uvareq = new UvaRequest();
 }
Beispiel #53
0
    public bool presist(UserDTO entity)
    {
        try
        {
            model.User obj = new User();
            obj.userName = entity.userName;
            obj.id = entity.id;
            obj.fullName = entity.fullName;
            obj.nickName = entity.nickName;
            obj.gender = entity.gender;
            obj.race = entity.race;
            obj.disabled = entity.disabled;
            obj.citizenship = entity.citizenship;
            obj.idType = entity.idType;
            obj.license = entity.license;
            obj.basicEducation = entity.basicEducation;
            obj.higherEducation = entity.higherEducation;
            obj.language = entity.language;
            obj.residentialAddress = entity.residentialAddress;
            obj.postalAddress = entity.postalAddress;
            obj.employed = entity.employed;
            obj.employmentHistory = entity.employmentHistory;

            ctx.Users.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
Beispiel #54
0
 public UserDAO()
 {
     ctx =  new ModelDataContext();//ModelFactory.getModelInstance();
 }
Beispiel #55
0
    public bool merge(UserDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.Users
                       where p.userName == @entity.userName && p.id == @entity.id
                       select p).Single();

            model.User obj = (User)addObj;

            /*Update*/
            obj.userName = entity.userName;
            obj.id = entity.id;
            obj.fullName = entity.fullName;
            obj.nickName = entity.nickName;
            obj.gender = entity.gender;
            obj.race = entity.race;
            obj.disabled = entity.disabled;
            obj.citizenship = entity.citizenship;
            obj.idType = entity.idType;
            obj.license = entity.license;
            obj.basicEducation = entity.basicEducation;
            obj.higherEducation = entity.higherEducation;
            obj.language = entity.language;
            obj.residentialAddress = entity.residentialAddress;
            obj.postalAddress = entity.postalAddress;
            obj.employed = entity.employed;
            obj.employmentHistory = entity.employmentHistory;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "User Merge: " + " ["+entity.userName+" , "+entity.id+"] " + e.Message;
            ctx.SubmitChanges();

            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
 public BasicEduSubjectDAO()
 {
     ctx = new ModelDataContext();// new ModelDataContext();//ModelFactory.getModelInstance();
 }
Beispiel #57
0
    public bool removeByUserId(string userName, string id)
    {
        try
        {
            var obj = (from p in ctx.Users
                       where p.userName == @userName && p.id == @id
                       select p).Single();

            User accObj = (User)obj;

            ctx.Users.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
Beispiel #58
0
    public bool merge(InboxDTO entity)
    {
        try
        {
            var addObj = (from p in ctx.Inboxes
                       where p.userName == @entity.userName && p.messageId == @entity.messageId
                       select p).Single();

            model.Inbox obj = (Inbox)addObj;

            /*Update*/
            obj.userName = entity.userName;
            obj.messageId = entity.messageId;
            obj.date = entity.date;
            obj.unread = entity.unread;
            obj.message = entity.message;

            ctx.SubmitChanges();
            return true;
        }
        catch (Exception e)
        {
            model.Log log = new Log();
            log.message = "Inbox Merge: " + " ["+entity.userName+" , "+entity.messageId+"] " + e.Message;
            ctx.SubmitChanges();

            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
Beispiel #59
0
    public bool removeByUserId(string userName, int messageId)
    {
        try
        {
            var obj = (from p in ctx.Inboxes
                       where p.userName == @userName && p.messageId == @messageId
                       select p).Single();

            model.Inbox accObj = (Inbox)obj;

            ctx.Inboxes.DeleteOnSubmit(accObj);
            ctx.SubmitChanges();
            return true;

        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }
    public bool presist(BasicEduSubjectDTO entity)
    {
        try
        {
            model.BasicEduSubject obj = new BasicEduSubject();
            obj.userName = entity.userName;
            obj.subjectName = entity.subjectName;
            obj.subjectDescription = entity.subjectDescription;

            ctx.BasicEduSubjects.InsertOnSubmit(obj);
            ctx.SubmitChanges();
            return true;
        }
        catch (Exception)
        {
            ctx.Dispose();
            ctx = new ModelDataContext();
            return false;
        }
    }