Exemplo n.º 1
0
        public void DeleteAll()
        {
            using (var db = new EfEntities())
            {
                db.Teams.Where(x => x.Deleted == false).Update(y => new Pb.Dal.Team() {Deleted = true, Modified = DateTime.Now});

                db.SaveChanges();
            }
        }
        public void Create(Guid notificationId, string externalId)
        {
            using (var db = new Pb.Dal.EfEntities())
            {
                Guid userId = db.Users.First(x => x.ExternalId == externalId).Id;

                db.NotificationPlayers.Add(new NotificationPlayer()
                {
                    Id = Guid.NewGuid(),
                    Created = DateTime.Now,
                    NotificationId = notificationId,
                    PlayerId = userId
                });

                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public void Create(Team team)
        {
            team.Created = DateTime.Now;
            team.Modified = DateTime.Now;

            using (var db = new Pb.Dal.EfEntities())
            {
                db.Teams.Add(new Pb.Dal.Team() {
                    Id = team.Id == Guid.Empty ? Guid.NewGuid() : team.Id,
                    Name = team.Name,
                    Description = team.Description,
                    Created = team.Created,
                    Modified = team.Modified,
                    Deleted = team.Deleted
                });
                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public void Create(List<Team> teams)
        {
            teams.ForEach(x => {
                x.Created = DateTime.Now;
                x.Modified = DateTime.Now;
            });

            using (var db = new Pb.Dal.EfEntities())
            {
                foreach (var team in teams)
                {
                    db.Teams.Add(new Pb.Dal.Team() {
                        Id = team.Id == Guid.Empty ? Guid.NewGuid() : team.Id,
                        Name = team.Name,
                        Description = team.Description,
                        Created = team.Created,
                        Modified = team.Modified,
                        Deleted = team.Deleted
                    });
                }

                db.SaveChanges();
            }
        }
Exemplo n.º 5
0
 public void Update(User user)
 {
     using (var db = new Pb.Dal.EfEntities())
     {
         db.Users.Where(x => x.Id == user.Id).Update(y => new Pb.Dal.User() {FirstName = user.FirstName, LastName = user.LastName, Callsign = user.Callsign, Modified = DateTime.Now});
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public void SetPassword(Guid userId, string password)
 {
     using (var db = new Pb.Dal.EfEntities())
     {
         db.Users.Where(x => x.Id == userId).Update(y => new Pb.Dal.User() {Password = _encryptor.Encrypt(password), Modified = DateTime.Now});
         db.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void Delete(Guid id)
 {
     using (var db = new Pb.Dal.EfEntities())
     {
         db.Users.Where(x => x.Id == id).Update(y => new Pb.Dal.User() {Deleted = true, Modified = DateTime.Now});
         db.SaveChanges();
     }
 }
Exemplo n.º 8
0
        public void Create(User user)
        {
            user.Created = DateTime.Now;
            user.Modified = DateTime.Now;

            //user.Password = _encryptor.Encrypt(user.Password);

            var efUser = ConvertUser(user);

            efUser.Password = "";

            using (var db = new Pb.Dal.EfEntities())
            {
                db.Users.Add(efUser);
                db.SaveChanges();
            }
        }
Exemplo n.º 9
0
        public void Create(Domain.Rank rank)
        {
            var efRank = Mapper.Map<Pb.Dal.Rank>(rank);

            efRank.Id = efRank.Id == Guid.Empty ? Guid.NewGuid() : efRank.Id;
            efRank.Created = DateTime.Now;
            efRank.Modified = DateTime.Now;
            efRank.Deleted = false;

            using (var db = new Pb.Dal.EfEntities())
            {
                db.Ranks.Add(efRank);
                db.SaveChanges();
            }
        }
Exemplo n.º 10
0
        public void DeleteByTeamId(Guid teamId)
        {
            using (var db = new EfEntities())
            {
                db.Ranks.Where(x => x.TeamId == teamId && x.Deleted == false).Update(y=> new Pb.Dal.Rank() {Deleted = true, Modified = DateTime.Now });

                db.SaveChanges();
            }
        }
Exemplo n.º 11
0
        public void Update(TeamModel team)
        {
            using (var db = new EfEntities())
            {
                db.Teams.Where(x => x.Deleted == false && x.Id == team.Id).Update(y => new Pb.Dal.Team()
                {
                    Modified = DateTime.Now,
                    Description = team.Description,
                    ImageUrl = team.ImageUrl,
                    Name = team.Name

                });

                db.SaveChanges();
            }
        }