private void DeleteSessionRecord()
        {
            var win = getSelectedValue();

            if (win == null || win.SessionID == 0)
            {
                Message(MessageTypes.Error, "Please Select to delete Session Detail");
                return;
            }
            if (!DeleteMessage())
            {
                return;
            }

            SessionRepo.Remove(win.SessionID);
            RefreshList();
        }
示例#2
0
        public async void Session_DeletedIsFalse_DeletedSetToTrueAfterCallingRemove()
        {
            var classes = new List <Class>()
            {
                new Class()
                {
                    Name       = "Into to Excel",
                    ShortName  = "CS 101",
                    CRN        = 24668,
                    Department = new Department()
                    {
                        Code = 134,
                        Name = "STEM"
                    }
                },
                new Class()
                {
                    Name       = "Advanced Datastructures",
                    ShortName  = "CS 387",
                    CRN        = 546789,
                    Department = new Department()
                    {
                        Code = 134,
                        Name = "STEM"
                    }
                }
            };
            var reasons = new List <Reason>()
            {
                new Reason()
                {
                    Id   = 1,
                    Name = "Bone Use"
                },
                new Reason()
                {
                    Id   = 2,
                    Name = "Computer Use"
                }
            };

            var person = new Person()
            {
                Email      = "*****@*****.**",
                FirstName  = "Tom",
                LastName   = "Betty",
                Id         = 4697,
                PersonType = PersonType.Student
            };
            var semester = new Semester()
            {
                Code = 201903
            };

            var session = new Session()
            {
                InTime         = DateTime.Now,
                OutTime        = DateTime.Now.Add(new TimeSpan(5)),
                PersonId       = person.Id,
                SemesterCode   = semester.Code,
                SessionClasses = new List <SessionClass>()
                {
                    new SessionClass()
                    {
                        ClassId = 24668
                    }
                },
                SessionReasons = new List <SessionReason>()
                {
                    new SessionReason()
                    {
                        ReasonId = 1
                    }
                },
                Deleted = false
            };

            db.Classes.AddRange(classes);
            db.People.Add(person);
            db.Semesters.Add(semester);
            db.Sessions.Add(session);
            db.SaveChanges();

            var deletedSession = await sessionRepo.Remove(x => x.Id == session.Id);

            Assert.True(deletedSession.Deleted);
        }