public static void DeleteNoteType(NoteType toDelete) { using (ProMaDB scope = new ProMaDB()) { foreach (PostedNote curNote in PostedNoteHandler.GetAllNotesOfType(toDelete.NoteTypeId)) { PostedNote updateThis = PostedNoteHandler.GetNote(curNote.NoteId); updateThis.NoteTypeId = null; updateThis.Active = false; PostedNoteHandler.UpdatePostedNote(updateThis); } foreach (NoteTypeMembership membership in NoteTypeMembershipHandler.GetMembershipsForType(toDelete.NoteTypeId)) { NoteTypeMembershipHandler.RemoveNoteTypeMembership(membership); } scope.NoteTypes.Attach(toDelete); scope.NoteTypes.Remove(toDelete); scope.SaveChanges(); ThisCache.Remove(toDelete); } }
public static void PermanentlyDeleteNote(PostedNote toDelete) { using (ProMaDB scope = new ProMaDB()) { scope.PostedNotes.Remove(toDelete); scope.SaveChanges(); } }
public static void UpdatePostedNote(PostedNote toUpdate) { using (ProMaDB scope = new ProMaDB()) { scope.PostedNotes.Attach(toUpdate); scope.Entry(toUpdate).State = EntityState.Modified; scope.SaveChanges(); } }
public static void AddPostedNote(PostedNote toAdd) { using (ProMaDB scope = new ProMaDB()) { scope.PostedNotes.Add(toAdd); scope.Entry(toAdd).State = EntityState.Added; scope.SaveChanges(); } }
public static PostedNote.PostedNotePayload GetPayloadNote(PostedNote raw, int?relevantUserId) { List <PostedNote.PostedNotePayload> returnThis = new List <PostedNote.PostedNotePayload>(); List <NoteType> noteTypes = new List <NoteType>(); if (relevantUserId.HasValue) { noteTypes = NoteTypeHandler.GetNoteTypesForUser(relevantUserId.Value); } return(new PostedNote.PostedNotePayload(raw, noteTypes)); }
public PostedNotePayload(PostedNote toMake, List <NoteType> hydratedNoteTypes) { Data = toMake; PostedUser = new PostedNoteProMaUserPayload(ProMaUserHandler.GetUser(toMake.UserId)); if (toMake.CompletedUserId.HasValue) { CompletedUser = new PostedNoteProMaUserPayload(ProMaUserHandler.GetUser(toMake.CompletedUserId.Value)); } if (toMake.EditedUserId.HasValue) { EditedUser = new PostedNoteProMaUserPayload(ProMaUserHandler.GetUser(toMake.EditedUserId.Value)); } TypeOfNote = hydratedNoteTypes.FirstOrDefault(x => x.NoteTypeId == toMake.NoteTypeId); }