Beispiel #1
0
        public MemberContentInteraction UpdateInteraction(string id, MemberContentInteraction interactionToUpdate)
        {
            if (!string.IsNullOrEmpty(interactionToUpdate.MemberContentComment) && interactionToUpdate.MemberContentComment.Length > 500)
            {
                interactionToUpdate.MemberContentComment = interactionToUpdate.MemberContentComment.Substring(0, 500);
            }

            if (!interactionToUpdate.IsValid())
            {
                throw new System.ComponentModel.DataAnnotations.ValidationException();
            }

            MemberContentInteraction memberContentInteraction = new MemberContentInteraction();

            int memberId = interactionToUpdate.MemberID.GetValueOrDefault();

            if (memberAdapter.IsCurrentUser(memberId.ToString()))
            {
                memberContentInteraction = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").UpdateInteraction(memberId, interactionToUpdate.ToMemberContentInteractionContract()).ToDomainObject();
            }
            else
            {
                throw new WebFaultException <string>("Not Authorized", System.Net.HttpStatusCode.Unauthorized);
            }

            return(memberContentInteraction);
        }
Beispiel #2
0
        public bool DeleteInteraction(string id, MemberContentInteraction interactionToDelete)
        {
            bool serviceResponse = false;
            int  memberId        = interactionToDelete.MemberID.GetValueOrDefault();

            if (memberAdapter.IsCurrentUser(memberId.ToString()))
            {
                serviceResponse = IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").DeleteInteraction(memberId, Int32.Parse(id));
                if (!serviceResponse)
                {
                    throw new WebFaultException <string>("{Failed to delete" + "}", System.Net.HttpStatusCode.BadRequest);
                }
            }
            else
            {
                throw new WebFaultException <string>("Not Authorized", System.Net.HttpStatusCode.Unauthorized);
            }

            return(serviceResponse);
        }
Beispiel #3
0
        public MemberContentInteraction AddInteraction(MemberContentInteraction interaction)
        {
            if (!string.IsNullOrEmpty(interaction.MemberContentComment) && interaction.MemberContentComment.Length > 500)
            {
                interaction.MemberContentComment = interaction.MemberContentComment.Substring(0, 500);
            }

            if (!interaction.IsValid())
            {
                throw new System.ComponentModel.DataAnnotations.ValidationException();
            }
            if (memberAdapter.IsCurrentUser(interaction.MemberID.ToString()))
            {
                return(IntegrationLoader.LoadDependency <ISaltServiceAgent>("saltServiceAgent").AddInteraction(interaction.ToMemberContentInteractionContract()).ToDomainObject());
            }
            else
            {
                throw new WebFaultException <string>("Not Authorized", System.Net.HttpStatusCode.Unauthorized);
            }
        }
Beispiel #4
0
 public static MemberContentInteractionContract ToMemberContentInteractionContract(this MemberContentInteraction interaction)
 {
     return(new MemberContentInteractionContract()
     {
         MemberContentInteractionID = interaction.MemberContentInteractionID,
         ContentID = interaction.ContentID,
         MemberID = interaction.MemberID,
         MemberContentInteractionValue = interaction.MemberContentInteractionValue,
         InteractionDate = interaction.InteractionDate,
         RefContentInteractionTypeID = interaction.RefContentInteractionTypeID,
         MemberContentComment = interaction.MemberContentComment
     });
 }