예제 #1
0
        public void AddNoteType([FromForm] string noteTypeName)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            if (noteTypeName.Contains("'") || noteTypeName.Contains("\""))
            {
                throw new Exception("Invalid Note Type name");
            }

            NoteType newNoteType = new NoteType();

            newNoteType.NoteTypeName = noteTypeName;
            NoteTypeHandler.AddNoteType(newNoteType);

            NoteTypeMembership originalMembership = new NoteTypeMembership();

            originalMembership.UserId      = user.UserId;
            originalMembership.NoteTypeId  = newNoteType.NoteTypeId;
            originalMembership.IsCreator   = true;
            originalMembership.CanUseNotes = true;
            NoteTypeMembershipHandler.AddNoteTypeMembership(originalMembership);
        }
예제 #2
0
        public void ShareNoteType([FromBody] ShareNoteTypeRequestObject requestObject)
        {
            ProMaUser user = DataController.LoggedInUser;

            if (user == null)
            {
                throw new NotLoggedInException();
            }

            NoteType relevantNoteType = NoteTypeHandler.GetNoteType(requestObject.noteTypeId, user.UserId);

            if (!relevantNoteType.Membership.IsCreator)
            {
                throw new Exception("Created by someone else");
            }

            NoteTypeMembership newMembership = new NoteTypeMembership();

            newMembership.NoteTypeId  = requestObject.noteTypeId;
            newMembership.CanUseNotes = requestObject.canEdit;
            newMembership.UserId      = requestObject.userId;
            NoteTypeMembershipHandler.AddNoteTypeMembership(newMembership);
        }