public void SectionsServicesAddShouldInvokeSaveChanges()
        {
            var section = new Section()
            {
                Description = "A descriptive description of the descriptor.",
                Name = "name"
            };

            this.sectionsService.Add(section);

            Assert.AreEqual(1, this.sectionsRepo.NumberOfSaves);
        }
        public static InMemoryRepository<Section> GetSectionsRepository(int numberOfCategories = 10)
        {
            var repo = new InMemoryRepository<Section>();
            var categories = GetCategoriesRepository(2);
            for (var i = 0; i < numberOfCategories; i++)
            {
                var section = new Section
                {
                    Id = i + 1,
                    Name = "Test Section " + i,
                    CategoryId = i % 2 + 1,
                    Category = categories.GetById(i % 2 + 1)
                };

                repo.Add(section);
            }

            return repo;
        }
 public void Update(Section section)
 {
     this.sections.Update(section);
     this.sections.SaveChanges();
 }
 public void Delete(Section section)
 {
     this.sections.Delete(section);
     this.sections.SaveChanges();
 }
 public void Add(Section section)
 {
     this.sections.Add(section);
     this.sections.SaveChanges();
 }
        public IHttpActionResult Put(int id, [FromBody] SectionRequestModel updates)
        {
            if (!this.ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var newSection = new Section
            {
                Id = id,
                Name = updates.Name,
                Description = updates.Description,
                CategoryId = updates.CategoryId
            };

            this.sections.Update(newSection);

            return this.Ok();
        }