//private int contentIdToBeDeleted; public async Task <bool> DeleteFile(int fileId, int contentId, UserFileDetails item) { try { var result = _context.UserFileDetails.FirstOrDefault(t => t.FileId == fileId); // this.contentIdToBeDeleted=contentId; // result.FileId=item.FileId; // result.ContentId=this.contentIdToBeDeleted; // result.UserId=item.UserId; // result.FilePath=item.FilePath; // result.FileType=item.FileType; // result.FileName=item.FileName; // result.IsPrivate=item.IsPrivate; // result.IsGraphCreated=item.IsGraphCreated; // result.IsFavourites=item.IsFavourites; result.IsDelete = true; //Soft delete of the file happens here. // result.CreatedOn=System.DateTime.Now; // result.CreatedBy=item.CreatedBy; // result.ModifiedOn=System.DateTime.Now; _context.UserFileDetails.Update(result); await _context.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(true); }
public async Task <bool> UpdateDetails(int fileId, UserFileDetails item) { try { var resultupdate = _context.UserFileDetails.FirstOrDefault(t => t.FileId == fileId); resultupdate.FileId = item.FileId; resultupdate.ContentId = item.ContentId; resultupdate.UserId = item.UserId; resultupdate.FilePath = item.FilePath; Console.WriteLine("filepath is {0}", resultupdate.FilePath); resultupdate.FileName = item.FileName; resultupdate.FileType = item.FileType; resultupdate.CreatedBy = item.CreatedBy; resultupdate.IsPrivate = item.IsPrivate; resultupdate.IsFavourites = item.IsFavourites; resultupdate.IsDelete = item.IsDelete; resultupdate.IsGraphCreated = false; //Since it is a new file, new graph database needs to be created for the uploaded file. resultupdate.CreatedOn = item.CreatedOn; resultupdate.ModifiedOn = System.DateTime.Now; _context.UserFileDetails.Update(resultupdate); await _context.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(true); }
public async Task <bool> CreateFileDetails(UserFileDetails item) { Console.WriteLine("Inside Create Files methods"); try { item.CreatedOn = System.DateTime.Now; item.ModifiedOn = System.DateTime.Now; //In order to add created on and modified on to the UserFileDetails database as the current date and time. _context.UserFileDetails.Add(item); try { await _context.SaveChangesAsync(); Console.WriteLine("FileID is {0}", item.FileId); Console.WriteLine("ContentID is {0}", item.ContentId); } catch (Exception ex) { Console.WriteLine(ex.Message); } } catch (Exception ex) { throw new Exception(ex.Message); } return(true); }
[HttpGet("{User_userID}/{User_contentID}")] //retrives all rows that matches both the prescribed userID and //contentID simultaneously public async Task <UserFileDetails> GetbyUser_userID(int User_userID, int User_contentID, [FromBody] UserDetails item) { try{ UserFileDetails todo = await _context.UserFileDetails.FirstOrDefaultAsync(t => (t.UserID == User_userID) && (t.ContentID == User_contentID)); return(todo); }catch (Exception ex) { throw new Exception(ex.Message); } }
[HttpPut("{fileId}")] //Update edited file. public Task <bool> UpdateDetails(int fileId, [FromBody] UserFileDetails item) { return(_service.UpdateDetails(fileId, item)); }
[HttpPut("{fileId}/{contentId}")] //Delete File corresponding to fileId by updating (IsDelete=true). public Task <bool> DeleteFile(int fileId, int contentId, [FromBody] UserFileDetails item) { return(_service.DeleteFile(fileId, contentId, item)); }
public Task <bool> CreateFileDetails([FromBody] UserFileDetails item) { return(_service.CreateFileDetails(item)); }
public async Task <UserFileDetails> GetbyUser_userID(int User_userID, [FromBody] UserDetails item) { UserFileDetails todo = await _context.UserFileDetails.FirstOrDefaultAsync(t => t.UserID == User_userID); return(todo); }