示例#1
0
        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)));
        }
示例#2
0
        public IActionResult GetLibrary(string id)
        {
            Library lib = Context.FindObjectById <Library>(id);

            if (lib != null)
            {
                return(Ok(LibraryValue.FromModel(lib)));
            }
            else
            {
                return(NotFound());
            }
        }
示例#3
0
        public IActionResult GetLibrariesForAccount()
        {
            Account acct = (Account)HttpContext.Items["Account"];

            return(Ok(LibraryValue.FromModel(acct.Libraries)));
        }