Exemple #1
0
        protected void Fetch_Click(object sender, EventArgs e)
        {
            if (List01.SelectedIndex == 0)
            {
                MessageLabel.Text = "Select a category to view its products";
            }
            else
            {
                try
                {
                    Controller01 sysmgr01 = new Controller01();
                    Entity01     info01   = null;
                    info01                  = sysmgr01.FindByID(int.Parse(List01.SelectedValue));
                    IDLabel01.Text          = "Category ID:";
                    IDLabel02.Text          = info01.CategoryID.ToString();
                    NameLabel01.Text        = "Category Name:";
                    NameLabel02.Text        = info01.CategoryName;
                    DescriptionLabel01.Text = "Category Description:";
                    DescriptionLabel02.Text = info01.Description;

                    Controller02    sysmgr02 = new Controller02();
                    List <Entity02> info02   = null;
                    info02 = sysmgr02.FindByID(int.Parse(List01.SelectedValue));
                    info02.Sort((x, y) => x.ProductName.CompareTo(y.ProductName));
                    List02.DataSource = info02;
                    List02.DataBind();
                }
                catch (Exception ex)
                {
                    MessageLabel.Text = ex.Message;
                }
            }
        }
Exemple #2
0
 protected void Fetch_Click(object sender, EventArgs e)
 {
     if (List01.SelectedIndex == 0)
     {
         MessageLabel.Text = "Select a category to view its products";
     }
     else
     {
         try
         {
             Controller01 sysmgr01 = new Controller01();
             Entity01     info01   = null;
             info01                  = sysmgr01.FindByPKID(int.Parse(List01.SelectedValue));
             NameLabel01.Text        = "Coach:";
             NameLabel02.Text        = info01.Coach;
             DescriptionLabel01.Text = "Assistant Coach:";
             DescriptionLabel02.Text = info01.AssistantCoach;
             IDLabel01.Text          = "Wins:";
             IDLabel02.Text          = info01.Wins.ToString();
             IDLabel201.Text         = "Losses:";
             IDLabel202.Text         = info01.Losses.ToString();
             Controller02    sysmgr02 = new Controller02();
             List <Entity02> info02   = null;
             info02 = sysmgr02.FindByID(int.Parse(List01.SelectedValue));
             info02.Sort((x, y) => x.FirstAndLast.CompareTo(y.FirstAndLast));
             List02.DataSource = info02;
             List02.DataBind();
         }
         catch (Exception ex)
         {
             MessageLabel.Text = ex.Message;
         }
     }
 }
Exemple #3
0
        public void ExcelEntity_CheckOuterXml_01()
        {
            // Arrange
            var expectedXml = @"<xx:tag />";

            var entity = new Entity01();

            // Act
            var outerXml = entity.OuterXml;

            // Assert
            Assert.AreEqual(expectedXml, outerXml);
        }
Exemple #4
0
        public void ExcelEntity_CheckOuterXml_02()
        {
            // Arrange
            var expectedXml = @"<xx:tag id=""id"" name=""name"" />";

            var entity = new Entity01();

            entity.Attributes.Add("id", "id");
            entity.Attributes.Add("name", "name");

            // Act
            var outerXml = entity.OuterXml;

            // Assert
            Assert.AreEqual(expectedXml, outerXml);
        }
        protected void Fetch_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(IDArg.Text))
            {
                MessageLabel.Text = "Enter a ID value.";
                ID.Text           = "";
                Name.Text         = "";
            }

            else
            {
                int id = 0;
                if (int.TryParse(IDArg.Text, out id))
                {
                    if (id > 0)
                    {
                        Controller01 sysmgr = new Controller01();
                        Entity01     info   = null;
                        info = sysmgr.FindByID(id); //BLL controller method

                        if (info == null)
                        {
                            MessageLabel.Text = "ID not found.";
                            ID.Text           = "";
                            Name.Text         = "";
                        }
                        else
                        {
                            ID.Text   = info.TeamID.ToString();
                            Name.Text = info.TeamName;
                        }
                    }
                    else
                    {
                        MessageLabel.Text = "ID must be greater than 0";
                        ID.Text           = "";
                        Name.Text         = "";
                    }
                }
                else
                {
                    MessageLabel.Text = "ID must be a number.";
                    ID.Text           = "";
                    Name.Text         = "";
                }
            }
        }
Exemple #6
0
        public void IntervalFieldTest()
        {
            var saveContext = new CodeFirstTestContext();
            var loadContext = new CodeFirstTestContext();

            var timestampsToCheck = new[]
            {
                TimeSpan.FromDays(-44),
                TimeSpan.FromDays(-4),
                TimeSpan.FromHours(-3),
                TimeSpan.FromMinutes(-2),
                TimeSpan.FromSeconds(-1),
                TimeSpan.Zero,
                TimeSpan.FromDays(1),
                TimeSpan.FromHours(2),
                TimeSpan.FromMinutes(3),
                TimeSpan.FromSeconds(4),
                TimeSpan.FromSeconds(44),
                new TimeSpan(-1, -2, -3),
                new TimeSpan(-1, -2, -3, -4),
                new TimeSpan(-1, -2, -3, -4, -567),
                new TimeSpan(1, 2, 3),
                new TimeSpan(1, 2, 3, 4),
                new TimeSpan(1, 2, 3, 4, 567),
                new TimeSpan(-1, 2, -3),
                new TimeSpan(1, -2, 3, -4),
                new TimeSpan(-1, 2, -3, 4, -567),
                new TimeSpan(-5, 2, -3, 4, -567)
            };

            foreach (var timeSpan in timestampsToCheck)
            {
                var entity = new Entity01 {
                    Interval = timeSpan
                };
                saveContext.Entities01.Add(entity);
                saveContext.SaveChanges();

                var loadFromDb = loadContext.Entities01.First(e => e.Id == entity.Id);

                Assert.AreEqual(entity.Interval, loadFromDb.Interval);
            }
        }
Exemple #7
0
        public void ExcelEntity_CheckOuterXml_03()
        {
            // Arrange
            var expectedXml = @"<xx:entity><xx:tag id=""id"" name=""name"" /></xx:entity>";

            var entity01 = new Entity01();

            entity01.Attributes.Add("id", "id");
            entity01.Attributes.Add("name", "name");

            var entity02 = new Entity02();

            entity02.Items = new List <ExcelEntity>()
            {
                entity01
            };

            // Act
            var outerXml = entity02.OuterXml;

            // Assert
            Assert.AreEqual(expectedXml, outerXml);
        }
Exemple #8
0
        public void EntityCreateTest()
        {
            var saveContext = new CodeFirstTestContext();
            var loadContext = new CodeFirstTestContext();

            // Round for safe comparision on next steps
            var time = TimeSpan.FromSeconds(Math.Round(DateTime.Now.TimeOfDay.TotalSeconds, 7));
            var date = DateTime.Now.Date + time;

            var saveToDb = new Entity01
            {
                TimeStamp = date,
                Time      = new DateTime(0u) + time,
                Interval  = time
            };

            saveContext.Entities01.Add(saveToDb);

            saveContext.SaveChanges();

            var loadFromDb = loadContext.Entities01.First(e => e.Id == saveToDb.Id);

            Assert.AreEqual(true, saveToDb.CompareTo(loadFromDb) == 0);
        }
 protected void Fetch_Click(object sender, EventArgs e)
 {
     if (List01.SelectedIndex == 0)
     {
         MessageLabel.Text = "Select a team to view details";
         //clear details
         Coach.Text          = "";
         AssistantCoach.Text = "";
         Wins.Text           = "";
         Losses.Text         = "";
     }
     else
     {
         try
         {
             Controller02    sysmgr = new Controller02();
             List <Entity02> info   = null;
             info = sysmgr.FindByID(int.Parse(List01.SelectedValue));
             info.Sort((x, y) => x.PlayerName.CompareTo(y.PlayerName));
             List02.DataSource = info;
             List02.DataBind();
             // Team info
             Controller01 teamController = new Controller01();
             Entity01     teamInfo       = null;
             teamInfo            = teamController.TeamGet(int.Parse(List01.SelectedValue));
             Coach.Text          = teamInfo.Coach;
             AssistantCoach.Text = teamInfo.AssistantCoach;
             Wins.Text           = teamInfo.Wins.ToString();
             Losses.Text         = teamInfo.Losses.ToString();
         }
         catch (Exception ex)
         {
             MessageLabel.Text = ex.Message;
         }
     }
 }