Ejemplo n.º 1
0
 public static void RegisterNewTeam(int ownerId, Team team)
 {
     using (var context = new ProbnikContext())
     {
         context.Teams.Add(team);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public static void CreateNewPerson(Person person)
 {
     using (var context = new ProbnikContext())
     {
         if (person.PESEL != null && !context.People.Any(p => p.PESEL == person.PESEL))
         {
             context.People.Add(person);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 3
0
 public static void RegisterNewUser(User user)
 {
     using (var context = new ProbnikContext())
     {
         if (user.isValid == true)
         {
             context.Users.Add(user);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks if login and password match
 /// </summary>
 /// <param name="Login"></param>
 /// <param name="password"></param>
 /// <returns>User commponent or null</returns>
 public static User Login(string Login, string password)
 {
     using (var context = new ProbnikContext())
     {
         User user = context.Users.Include(u => u.People).SingleOrDefault(u => u.Login == Login);
         if (user != null)
         {
             return(user.PasswordMatch(password) ? user : null);
         }
         return(null);
     }
 }
Ejemplo n.º 5
0
        public static bool ConnectUserToPerson(int userId, int personId, string key, ConnectionType connectionType)
        {
            using (var context = new ProbnikContext())
            {
                var person = context.People.Single(p => p.Id == personId);

                if (person.ConnectionKey == key)
                {
                    var connection = new UserToPersonConnection(userId, person.Id.Value, connectionType);
                    context.UserToPersonConnections.Add(connection);
                    person.GenerateNewKey();
                    context.SaveChanges();
                }
            }
            return(false);
        }
Ejemplo n.º 6
0
        private static void Test()
        {
            var context = new ProbnikContext();

            User user = new User();

            user.Login    = "******";
            user.Email    = "*****@*****.**";
            user.IsAdmin  = true;
            user.Password = "******";

            //context.Users.AddOrUpdate(user);

            Person person = new Person("Wiktor", "Matecki", "18-08-1997");

//            UserToPersonConnection upc = new UserToPersonConnection();
//            upc.User = user;
//            upc.Person = person;
//
//            person.Users.Add(upc);


            //context.People.AddOrUpdate(person);

            //context.SaveChanges();

            Methodology HS = new Methodology();

            HS.Name = "Harcerze Starsi";

            //context.Methodologies.AddOrUpdate(HS);

            Methodology w = new Methodology();

            w.Name = "Wędrownicy";
            //context.Methodologies.AddOrUpdate(w);

            Patron patron = new Patron();

            patron.Person = person;

            Team b = new Team();

            b.Name = "Berserk";
            b.Methodologies.Add(HS);
            b.Patrons.Add(patron);

            context.Teams.AddOrUpdate(b);

            Team e = new Team();

            e.Name = "Emilki";
            e.Methodologies.Add(w);
            context.Teams.AddOrUpdate(e);

            //context.SaveChanges();

            //HS = context.Methodologies.First(m => m.Name == "Harcerze Starsi");
            TaskContent task1 = new TaskContent();

            task1.Content    = "Wyzwanie sportowe";
            task1.TaskNumber = 1;

            var task2 = new TaskContent()
            {
                Content    = "Wyzwanie duchowe",
                TaskNumber = 2
            };

            ChallangeType challengeType = new ChallangeType();

            challengeType.Methodologies.Add(HS);
            challengeType.Name = "Odkrywca";
            challengeType.Tasks.Add(task1);
            challengeType.Tasks.Add(task2);

            context.ChallangeTypes.Add(challengeType);
            context.SaveChanges();

            //var unit = new UnitOfWork(context);

            //var p = unit.People.Get(0);
            //var c = new UserToPersonConnection();

            //unit.Users.Get(0);
        }