public override async Task <IActionResult> Post([FromBody] Event docIn)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // check required properties
            if (docIn.Name == null)
            {
                return(MissingPropertyResult("name"));
            }
            if (docIn.Band == null)
            {
                return(MissingPropertyResult("band"));
            }

            // remove unused properties
            docIn.Songs       = new List <string>();
            docIn.Users       = new List <string>();
            docIn.CurrentSong = null;

            // get band if it exists
            string bandId         = docIn.Band;
            string bandCollection = CollectionNames.BANDS;
            Band   band           = null;

            try
            {
                band = await CosmosRepo.GetDocument <Band>(bandCollection, bandId);
            }
            catch (DocumentClientException)
            {
                return(ItemNotFoundResult(bandId, bandCollection));
            }

            // create event
            Event created = await CosmosRepo.CreateDocument(CollectionName, docIn);

            string eventId = created.Id;

            // update band
            if (!band.Events.Contains(eventId))
            {
                List <string> events = band.Events.ToList();
                events.Add(eventId);
                band.Events = events;
                await CosmosRepo.ReplaceDocument(bandCollection, bandId, band);
            }

            return(Created(GetGetUri(eventId), created));
        }
        public override async Task <IActionResult> Post([FromBody] Part docIn)
        {
            // make sure required fields are included
            if (docIn.Instrument == null)
            {
                return(MissingPropertyResult("instrument"));
            }
            if (docIn.Song == null)
            {
                return(MissingPropertyResult("song"));
            }
            docIn.Path = null;

            // make sure song exists
            string songsCollection = ConstantNames.SONGS;
            string songId          = docIn.Song;
            Song   song;

            try
            {
                song = await CosmosRepo.GetDocument <Song>(songsCollection, songId);
            }
            catch (DocumentClientException)
            {
                return(ItemNotFoundResult(songId, songsCollection));
            }

            // create part
            Part newDoc = await CosmosRepo.CreateDocument(CollectionName, docIn);

            string partId = newDoc.Id;

            // update song
            if (!song.Parts.Contains(partId))
            {
                List <string> parts = song.Parts.ToList();
                parts.Add(partId);
                song.Parts = parts;
                await CosmosRepo.ReplaceDocument(songsCollection, songId, song);
            }

            return(Created(GetGetUri(newDoc.Id), newDoc));
        }