public IHttpActionResult PostSlideBefore(Guid slideshowId, Guid slideId, SlideInputModel model) { if (slideshowId == null || slideId == null) { return NotFound(); } var slideshow = SlideshowRepository.Find(slideshowId); var referencedSlide = slideshow.Slides.FirstOrDefault(x => x.Id == slideId); if (slideshow == null || referencedSlide == null) { return NotFound(); } var slide = new Slide(new Colour(model.BackgroundColourHexCode), Duration.From(model.DurationInSeconds), Transition.From(model.TransitionType), model.Name); if (model.IsActive) { slide.ActivateSlide(); } else { slide.DeactivateSlide(); } slideshow.InsertBefore(slide, referencedSlide); SlideshowRepository.Update(slideshow); return Created(new Uri(Url.Link("GetSlide", new { companyId = slideshow.CompanyId, slideshowId = slideshow.Id, slideId = slide.Id })), SlideModel.From(slide)); }