示例#1
0
        public void User_Can_Add_New_Snag()
        {
            var repo          = new SnagRepository(_context);
            var startingSnags = repo.GetByRibbon(1);
            var startingCount = startingSnags.Count;

            var newSnag = new Snag()
            {
                RibbonId    = 1,
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
                Note        = "snag note 1",
                Seconds     = 70
            };

            //add new snag
            repo.Add(newSnag);

            //Get all snags again
            var resultingRibbons = repo.GetByRibbon(1);
            var resultingCount   = resultingRibbons.Count;

            //Check that one has been added
            Assert.NotEqual(0, newSnag.Id);
            Assert.Equal(startingCount + 1, resultingCount);
        }
 public IActionResult Put(int id, Snag snag)
 {
     if (id != snag.Id)
     {
         return(BadRequest());
     }
     snag.DateCreated = DateTime.Now;
     _snagRepo.Update(snag);
     return(NoContent());
 }
示例#3
0
        //Add sample data
        public void AddSampleData()
        {
            var user1 = new UserProfile()
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                ImageUrl       = "image.jpeg",
                FirebaseUserId = "TEST_FIREBASE_UID_2"
            };

            var user2 = new UserProfile()
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                ImageUrl       = "image.jpeg",
                FirebaseUserId = "TEST_FIREBASE_UID_2"
            };

            _context.Add(user1);
            _context.Add(user2);
            _context.SaveChanges();

            var source1 = new Source()
            {
                Type = "youtube",
            };

            var source2 = new Source()
            {
                Type = "local",
            };

            _context.Add(source1);
            _context.Add(source2);
            _context.SaveChanges();

            var category1 = new Category()
            {
                Name          = "Sports",
                UserProfileId = 1
            };

            var category2 = new Category()
            {
                Name          = "Tech",
                UserProfileId = 1
            };
            var category3 = new Category()
            {
                Name          = "Games",
                UserProfileId = 2
            };

            _context.Add(category1);
            _context.Add(category2);
            _context.Add(category3);
            _context.SaveChanges();

            var ribbon1 = new Ribbon()
            {
                Title       = "Test Video 1",
                Decription  = "decription of test video 1",
                CategoryId  = 1,
                SourceId    = 1,
                URL         = "www.url.com",
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
            };
            var ribbon2 = new Ribbon()
            {
                Title       = "Test Video 2",
                Decription  = "decription of test video 2",
                CategoryId  = 1,
                SourceId    = 1,
                URL         = "www.url.com",
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
            };

            var ribbon3 = new Ribbon()
            {
                Title       = "Test Video 3",
                Decription  = "decription of test video 3",
                CategoryId  = 2,
                SourceId    = 2,
                URL         = "www.url.com",
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
            };

            var ribbon4 = new Ribbon()
            {
                Title       = "Test Video 4",
                Decription  = "decription of test video 4",
                CategoryId  = 3,
                SourceId    = 2,
                URL         = "www.url.com",
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
            };

            _context.Add(ribbon1);
            _context.Add(ribbon2);
            _context.Add(ribbon3);
            _context.Add(ribbon4);
            _context.SaveChanges();

            var snag1 = new Snag()
            {
                RibbonId    = 1,
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
                Note        = "snag note 1",
                Seconds     = 30
            };

            var snag2 = new Snag()
            {
                RibbonId    = 1,
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
                Note        = "snag note 2",
                Seconds     = 45
            };

            var snag3 = new Snag()
            {
                RibbonId    = 2,
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
                Note        = "snag note 3",
                Seconds     = 30
            };

            var snag4 = new Snag()
            {
                RibbonId    = 2,
                DateCreated = DateTime.Now - TimeSpan.FromDays(365),
                Note        = "snag note 4",
                Seconds     = 55
            };

            _context.Add(snag1);
            _context.Add(snag2);
            _context.Add(snag3);
            _context.Add(snag4);
            _context.SaveChanges();
        }
 public IActionResult Post(Snag snag)
 {
     snag.DateCreated = DateTime.Now;
     _snagRepo.Add(snag);
     return(CreatedAtAction("Get", new { id = snag.Id }, snag));
 }
示例#5
0
 public void Update(Snag snag)
 {
     _context.Entry(snag).State = EntityState.Modified;
     _context.SaveChanges();
 }
示例#6
0
 public void Add(Snag snag)
 {
     _context.Add(snag);
     _context.SaveChanges();
 }