Пример #1
0
        private void OnSaveClick()
        {
            foreach (Organizer user in OrgReg)
            {
                if (user.Login == RegLogin)
                {
                    throw new Exception("Такой Логин уже используется");
                }
            }
            foreach (Group user in GroupReg)
            {
                if (user.Login == RegLogin)
                {
                    throw new Exception("Такой Логин уже используется");
                }
            }


            var rep = new SQLRepository();

            if (IsOrganizer)
            {
                OrgReg.Add(new Organizer
                {
                    Login       = RegLogin,
                    Password    = RegPassword,
                    Name        = RegName,
                    Telephone   = RegTelephone,
                    Mail        = RegMail,
                    Information = RegInformation,
                    //IsOrganizer = true
                });

                rep.AddOrganizer(OrgReg[OrgReg.Count - 1]);
                rep.Save();
            }
            else
            {
                GroupReg.Add(new Group
                {
                    Login       = RegLogin,
                    Password    = RegPassword,
                    Name        = RegName,
                    Telephone   = RegTelephone,
                    Mail        = RegMail,
                    Information = RegInformation,
                    //IsOrganizer = false
                });
                rep.AddGroup(GroupReg[GroupReg.Count - 1]);
                rep.Save();
            }

            Close();
        }