public HttpResponseMessage ArchiveLibraryResource(string token, int DocID) { if (context.IsUserInternal(token) != 1) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } Library_Resource _Resource = context.Library_Resources.Single(i => i.Id == DocID); _Resource.IsArchived = true; context.SubmitChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public HttpResponseMessage UploadLibraryResource(string token, [FromBody] Library_Resource_DTO resource) { if (context.CheckIfTokenValid(token) != 10001 && context.IsUserInternal(token) == 1) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } try { //generate a unique quid for filename string storedGuid = Guid.NewGuid().ToString(); Library_Resource library_Resource = new Library_Resource { DocumentName = resource.DocumentName, ResourceTypeID = resource.ResourceTypeID, SpecificClientID = resource.SpecificCLientID, StoredGuid = storedGuid, VersionNumber = resource.VersionNumber, DocExt = resource.DocExt, MIMEType = resource.MIMEType }; context.Library_Resources.InsertOnSubmit(library_Resource); //save the file with the unique guid File.WriteAllBytes(path + storedGuid, Convert.FromBase64String(resource.Base64)); context.SubmitChanges(); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("Uploaded") }); } catch (Exception e) { ExceptionLog.LogException(e); return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }