public IActionResult CreateLibrary([FromBody] LibraryValue libValue) { var libName = libValue.LibraryName; if (String.IsNullOrEmpty(libName)) { return(BadRequest()); } // check if library exists already Library lib = Context.FindLibrary(libName); if (lib != null) { return(BadRequest()); } lib = new Library() { Account = (Account)HttpContext.Items["Account"], LibraryName = libName, AssetCollection = $"assets_{Path.GetFileNameWithoutExtension(Path.GetRandomFileName())}" }; Context.Libraries.InsertOne(lib); return(Ok(LibraryValue.FromModel(lib))); }
public IActionResult GetLibrary(string id) { Library lib = Context.FindObjectById <Library>(id); if (lib != null) { return(Ok(LibraryValue.FromModel(lib))); } else { return(NotFound()); } }
public IActionResult GetLibrariesForAccount() { Account acct = (Account)HttpContext.Items["Account"]; return(Ok(LibraryValue.FromModel(acct.Libraries))); }