public m_section_overview UpsertSection(Guid courseID, m_section_overview section) { Course course; Section s = null; if (section.id.IsNullOrEmpty()) GetCourse(courseID, out course); else GetCourseAndSection(courseID, section.id, out course, out s); if (s == null) { s = new Section {SortOrder = course.Sections.Count}; course.Sections.Add(s); } s.Title = section.title; _entityRepository.Save(course); return s; }
public m_section_overview UpsertSection(Guid courseID, m_section_overview section) { return new SectionControllerTests().UpsertSection(courseID, section); }
public m_section_overview UpsertSection(Guid courseID, m_section_overview section) { return ExecutePutRequest<m_section_overview>(courseID.ToString(), section); }
public void CanUpsertAndDeleteSection() { var course = GetCourses().FirstOrDefault(); Assert.IsNotNull(course); var section = new m_section_overview {title = "Newly Created Section"}; var newSection = UpsertSection(course.id, section); Assert.IsNotNull(newSection); Assert.IsFalse(newSection.id.IsNullOrEmpty()); Assert.AreEqual(section.title, newSection.title); newSection.title = "Updated Section Title"; var updatedSection = UpsertSection(course.id, newSection); Assert.IsNotNull(updatedSection); Assert.AreEqual(newSection.id, updatedSection.id); Assert.AreEqual(newSection.title, updatedSection.title); DeleteSection(course.id, updatedSection.id); section = GetSections(course.id).FirstOrDefault(s=>s.id == updatedSection.id); Assert.IsNull(section); }
public void RenameSection(Guid courseID, m_section_overview section) { ExecutePutRequest("rename/" + courseID + "/" + section.id, section.title); }