// PUT: api/Collections public IHttpActionResult Put([FromBody] CollectionAPI collectionApi) { if (!ModelState.IsValid) { return(BadRequest()); } try { Collection oldcollection = _collectionRepository.GetById(collectionApi.Id); if (oldcollection == null) { _collectionRepository.Insert(collectionApi.ToCollectionNoBookmarks()); } else { Collection updatedColl = collectionApi.ToCollectionNoBookmarks(); updatedColl.Bookmarks = oldcollection.Bookmarks; updatedColl.Created = oldcollection.Created; _collectionRepository.Update(updatedColl); } } catch (Exception ex) { // TODO: Log errors return(InternalServerError(ex)); } return(Ok()); }
// POST: api/Collections public IHttpActionResult Post([FromBody] CollectionAPI collectionApi) { if (!ModelState.IsValid) { return(BadRequest()); } _collectionRepository.Insert(collectionApi.ToCollectionNoBookmarks()); return(Ok()); }