Exemplo n.º 1
0
        public void SaveMemberAvatar(MemberAvatar avatar)
        {
            using (var context = new ScrumFactoryEntities(this.connectionString)) {
                MemberProfile oldMember = GetMember(avatar.MemberUId);

                MemberAvatar oldAvatar = GetMemberAvatar(avatar.MemberUId);

                if (oldMember == null)
                {
                    throw new System.Exception("member not found");
                }

                if (oldAvatar == null)
                {
                    context.MembersAvatar.AddObject(avatar);
                }
                else
                {
                    context.AttachTo("MembersAvatar", oldAvatar);
                    context.ApplyCurrentValues <MemberAvatar>("MembersAvatar", avatar);
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public void RemoveMemberAvatar(string memberUId)
 {
     using (var context = new ScrumFactoryEntities(this.connectionString)) {
         MemberAvatar avatar = context.MembersAvatar.SingleOrDefault(a => a.MemberUId == memberUId);
         if (avatar != null)
         {
             context.MembersAvatar.DeleteObject(avatar);
             context.SaveChanges();
         }
     }
 }