public void UpdateTest()
        {
            //Load up Guids
            PerformerList performers = new PerformerList();
            Performer     performer  = new Performer();

            performers.Load();
            performer = performers.FirstOrDefault(p => p.FirstName == "Hunter");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            InstrumentList instruments = new InstrumentList();
            Instrument     instrument  = new Instrument();

            instruments.Load();
            instrument = instruments.FirstOrDefault(c => c.Description == "Euphonium");

            GroupMember     groupMember  = new GroupMember();
            GroupMemberList groupMembers = new GroupMemberList();

            groupMembers.Load();
            groupMember           = groupMembers.FirstOrDefault(p => p.GroupId == group.Id && p.PerformerId == performer.Id);
            groupMember.StartDate = Convert.ToDateTime("04/24/3000");
            groupMember.EndDate   = Convert.ToDateTime("04/25/3000");

            groupMember.Instrument = instrument.Id;
            int results = groupMember.Update();

            Assert.IsTrue(results == 1);
        }
Beispiel #2
0
 T GetEntityByID <T>(Guid id) where T : IStoryEntityObject
 {
     if (typeof(IActor).IsAssignableFrom(typeof(T)))
     {
         var r = ActorList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     if (typeof(IEvent).IsAssignableFrom(typeof(T)))
     {
         var r = EventList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     if (typeof(IGroup).IsAssignableFrom(typeof(T)))
     {
         var r = GroupList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     if (typeof(IStuff).IsAssignableFrom(typeof(T)))
     {
         var r = StuffList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     if (typeof(ITask).IsAssignableFrom(typeof(T)))
     {
         var r = TaskList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     if (typeof(ILocation).IsAssignableFrom(typeof(T)))
     {
         var r = LocationList.FirstOrDefault(v => v.ObjectID == id);
         if (r == null)
         {
             return(default(T));
         }
         return((T)r);
     }
     return(default(T));
 }
Beispiel #3
0
        public void DeleteTest()
        {
            Group     group  = new Group();
            GroupList groups = new GroupList();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "BL Test");

            int results = group.Delete();

            Assert.IsTrue(results == 1);
        }
Beispiel #4
0
        public void LoadById()
        {
            Group     group  = new Group();
            GroupList groups = new GroupList();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "BL Test");

            Group newGroup = new Group {
                Id = group.Id
            };

            newGroup.LoadById();

            Assert.AreEqual(group.Name, newGroup.Name);
        }
        public void LoadById()
        {
            //Load up Guids
            PieceList pieces = new PieceList();
            Piece     piece  = new Piece();

            pieces.Load();
            piece = pieces.FirstOrDefault(p => p.Name == "Rock Music");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            PerformanceList performances = new PerformanceList();
            Performance     performance  = new Performance();

            performances.Load();
            performance = performances.FirstOrDefault(c => c.Name == "Dream Concert");

            DirectorList directors = new DirectorList();
            Director     director  = new Director();

            directors.Load();
            director = directors.FirstOrDefault(c => c.FirstName == "Eric");

            PerformancePiece     performancePiece  = new PerformancePiece();
            PerformancePieceList performancePieces = new PerformancePieceList();

            performancePieces.Load();
            performancePiece         = performancePieces.FirstOrDefault(p => p.GroupId == group.Id && p.PieceId == piece.Id && p.PerformanceId == performance.Id);
            performancePiece.Notes   = "BL Test";
            performancePiece.MP3Path = "BL Test";

            PerformancePiece newperformancePiece = new PerformancePiece {
                Id = performancePiece.Id
            };

            newperformancePiece.LoadById();

            Assert.AreEqual(performancePiece.DirectorId, newperformancePiece.DirectorId);
        }
        /// <summary>
        /// Populate the other groups dropdown and select the relevent User group.
        /// </summary>
        /// <param name="groups">The available groups.</param>
        private void Populate(GroupList groups)
        {
//			this.otherGroups.ItemsSource = groups;
            if (this.Group == null)
            {
                this.otherGroups.PersistentSelectedValue = groups.FirstOrDefault(g => (g as Group).GroupType == GroupType.User).EntityId;
            }
            else
            if (this.Group.GroupType == GroupType.User && this.Group.TenantId == this.Tenant)
            {
                this.standardUser.IsChecked = true;
            }
            else if (this.Group.GroupType != GroupType.Custom && this.Group.TenantId == this.Tenant)
            {
                this.administrator.IsChecked = true;
            }
            else
            {
                this.other.IsChecked = true;
            }
        }
        public void UpdateTest()
        {
            //Load up Guids
            PieceList pieces = new PieceList();
            Piece     piece  = new Piece();

            pieces.Load();
            piece = pieces.FirstOrDefault(p => p.Name == "Rock Music");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            PerformanceList performances = new PerformanceList();
            Performance     performance  = new Performance();

            performances.Load();
            performance = performances.FirstOrDefault(c => c.Name == "Dream Concert");

            DirectorList directors = new DirectorList();
            Director     director  = new Director();

            directors.Load();
            director = directors.FirstOrDefault(c => c.FirstName == "Eric");

            PerformancePiece     performancePiece  = new PerformancePiece();
            PerformancePieceList performancePieces = new PerformancePieceList();

            performancePieces.Load();
            performancePiece         = performancePieces.FirstOrDefault(p => p.GroupId == group.Id && p.PieceId == piece.Id && p.PerformanceId == performance.Id);
            performancePiece.Notes   = "BL Test";
            performancePiece.MP3Path = "BL Test";

            performancePiece.DirectorId = director.Id;
            int results = performancePiece.Update();

            Assert.IsTrue(results == 1);
        }
        public void LoadById()
        {
            //Load up Guids
            PerformerList performers = new PerformerList();
            Performer     performer  = new Performer();

            performers.Load();
            performer = performers.FirstOrDefault(p => p.FirstName == "Hunter");

            GroupList groups = new GroupList();
            Group     group  = new Group();

            groups.Load();
            group = groups.FirstOrDefault(c => c.Name == "Jazz Ensemble");

            InstrumentList instruments = new InstrumentList();
            Instrument     instrument  = new Instrument();

            instruments.Load();
            instrument = instruments.FirstOrDefault(c => c.Description == "Euphonium");

            GroupMember     groupMember  = new GroupMember();
            GroupMemberList groupMembers = new GroupMemberList();

            groupMembers.Load();
            groupMember           = groupMembers.FirstOrDefault(p => p.GroupId == group.Id && p.PerformerId == performer.Id);
            groupMember.StartDate = Convert.ToDateTime("04/24/3000");
            groupMember.EndDate   = Convert.ToDateTime("04/25/3000");

            GroupMember newgroupmember = new GroupMember {
                Id = groupMember.Id
            };

            newgroupmember.LoadById();

            Assert.AreEqual(groupMember.Instrument, newgroupmember.Instrument);
        }
Beispiel #9
0
        public void CreateOrUpdateGr(DataBaseMotion motion, int index, SveraGrFormDataBase sveraGrDataBase)
        {
            SQLiteConnection SQLconnect = null;
            SQLiteCommand    command    = null;

            try
            {
                string filePath = FunctionUse.GetDataBasePath();
                if (File.Exists(filePath) == true)
                {
                    FunctionUse.CopyDataBase(filePath);

                    SQLconnect = new SQLiteConnection();
                    SQLconnect.ConnectionString  = "Data Source=" + FunctionUse.GetDataBasePath() + ";";
                    SQLconnect.ParseViaFramework = true;
                    SQLconnect.Open();

                    using (var transaction = SQLconnect.BeginTransaction())
                    {
                        string sqlCom = "";

                        FunctionUse.TestTableAndColumns(SQLconnect);

                        if (motion == DataBaseMotion.Delete)
                        {
                            if (sveraGrDataBase != null && sveraGrDataBase.IdBase > 0)
                            {
                                sqlCom = "DELETE FROM GroupTable " +
                                         "WHERE Id = " + sveraGrDataBase.IdBase
                                ;
                            }
                            else
                            {
                                MessageBox.Show("Текущая запись не существует", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        else
                        {
                            FromDataBaseWide detilizeId = GroupList.FirstOrDefault <FromDataBaseWide>(fr => fr.Id == Detalized[index].Id);


                            if (detilizeId != null && detilizeId.IdBase > 0)
                            {
                                //string insertTest = "WHERE NOT EXISTS  (SELECT 1 FROM GroupTable WHERE " +
                                //                                        "naimId = " + detilizeId.IdBase +
                                //                                        ")";
                                sqlCom = "INSERT OR REPLACE" +
                                         " INTO GroupTable (id, naimId, groupId) " +
                                         "SELECT " +
                                         ((motion == DataBaseMotion.Insert) ? "NULL" : sveraGrDataBase.IdBase.ToString()) +
                                         ", " + detilizeId.IdBase + "" +
                                         ", '" + HashKolAndId(Detalized[index].GridGroupId) + "'" //+
                                                                                                  //   " " +
                                                                                                  // ((motion == DataBaseMotion.Insert) ? insertTest : "")
                                ;
                            }
                            else
                            {
                                MessageBox.Show("Текущей группе не присвоен ID базы", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        command = new SQLiteCommand(sqlCom, SQLconnect);
                        command.ExecuteNonQuery();

                        transaction.Commit();

                        if (motion == DataBaseMotion.Insert)
                        {
                            MessageBox.Show("Запись добавлена в базу", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (motion == DataBaseMotion.Update)
                        {
                            MessageBox.Show("Запись обновлена в базе", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else if (motion == DataBaseMotion.Delete)
                        {
                            MessageBox.Show("Запись удалена из базы", "Svera DataBase", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                    if (command != null)
                    {
                        command.Dispose();
                    }
                    if (SQLconnect != null)
                    {
                        SQLconnect.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                if (SQLconnect != null)
                {
                    SQLconnect.Close();
                }
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    MessageBox.Show(ex.InnerException.ToString());
                }
            }
        }