public bool UpdateCollaborators(AddCollaboratorsModel collaborators) { try { NotesDB.Collaborators.RemoveRange( NotesDB.Collaborators.Where(n => n.NoteId == collaborators.NoteID)); NotesDB.SaveChanges(); if (collaborators.Collaborators != null) { foreach (var collaborator in collaborators.Collaborators) { NotesDB.Collaborators.Add( new Collaborator { UserId = collaborators.UserID, NoteId = collaborators.NoteID, CollaboratorEmail = collaborator }); } NotesDB.SaveChanges(); return(true); } } catch (Exception) { throw; } return(false); }
public async Task <bool> UpdateCollaborators(AddCollaboratorsModel collaborators) { try { await redis.RemoveNotesRedisCache(collaborators.UserID); return(NotesManagementRL.UpdateCollaborators(collaborators)); } catch (Exception) { throw; } }
public IActionResult UpdateCollaborators(AddCollaboratorsModel Collaborators) { try { var identity = User.Identity as ClaimsIdentity; if (identity != null) { IEnumerable <Claim> claims = identity.Claims; long UserID = Convert.ToInt64(claims.Where(p => p.Type == "UserID").FirstOrDefault()?.Value); Collaborators.UserID = UserID; bool result = notesManagementBL.UpdateCollaborators(Collaborators).Result; return(Ok(new { success = true, Message = "collaborators updated", Note = result })); } return(BadRequest(new { success = false, Message = "no user is active please login" })); } catch (Exception exception) { return(BadRequest(new { success = false, exception.Message })); } }