コード例 #1
0
ファイル: LinkRepository.cs プロジェクト: greinedt/GiftList
 public IList<LinkEntity> GetAllLinks()
 {
     using (Connection conn = new Connection())
     {
         return GetAllLinks(conn);
     }
 }
コード例 #2
0
 public IList<ItemCommentEntity> GetAllItemComments()
 {
     using (Connection conn = new Connection())
     {
         return GetAllItemComments(conn);
     }
 }
コード例 #3
0
ファイル: PersonRepository.cs プロジェクト: greinedt/GiftList
 public IList<PersonEntity> GetAllPersons()
 {
     using (Connection conn = new Connection())
     {
         return GetAllPersons(conn);
     }
 }
コード例 #4
0
 public void Delete(int id)
 {
     using (Connection conn = new Connection())
     {
         Delete(id, conn);
     }
 }
コード例 #5
0
 public IList<PurchaseEntity> GetAllPurchases()
 {
     using (Connection conn = new Connection())
     {
         return GetAllPurchases(conn);
     }
 }
コード例 #6
0
 public IList<GroupMemberEntity> GetAllGroupMembers()
 {
     using (Connection conn = new Connection())
     {
         return GetAllGroupMembers(conn);
     }
 }
コード例 #7
0
 public void Delete(List<int> batch)
 {
     using (Connection conn = new Connection())
     {
         Delete(batch,conn);
     }
 }
コード例 #8
0
 public IList<GiftListGroupEntity> GetAllGiftListGroups()
 {
     using (Connection conn = new Connection())
     {
         return GetAllGiftListGroups(conn);
     }
 }
コード例 #9
0
 public void Delete(List<int> batch)
 {
     using (Connection conn = new Connection())
     {
         conn.BeginTransaction();
         try {
             Delete(batch, conn);
         }
         catch(Exception e)
         {
             conn.RollbackTransaction();
             throw e;
         }
         conn.CommitTransaction();
     }
 }
コード例 #10
0
 public void Update(List<GroupMemberEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Update(batch, conn);
     }
 }
コード例 #11
0
 public void Update(int id, GroupMemberEntity groupMember)
 {
     using (Connection conn = new Connection())
     {
         Update(id, groupMember, conn);
     }
 }
コード例 #12
0
 public void Insert(List<GroupMemberEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Insert(batch, conn);
     }
 }
コード例 #13
0
 public bool GiftListGroupExists(int giftList, int group)
 {
     using (Connection conn = new Connection())
     {
         return GiftListGroupExists(giftList, group, conn);
     }
 }
コード例 #14
0
 public void Update(int id, ItemCommentEntity itemComment)
 {
     using (Connection conn = new Connection())
     {
         Update(id, itemComment, conn);
     }
 }
コード例 #15
0
        public long Insert(GiftListGroupEntity giftListGroup, IConnection conn)
        {
            CheckGiftListGroupForRequiredValues(giftListGroup, RepositoryUtils.RepositoryAction.Insert);
            using (Connection _conn = new Connection())
            {
                var giftListGroupExists = GetGiftListGroup(giftListGroup.giftListFK, giftListGroup.groupFK);
                if (giftListGroupExists != null)
                {
                    throw new Exception($"Gift List Group {giftListGroup.giftListFK} {giftListGroup.groupFK} already exists in database!");
                }

                string sql =
                    @"INSERT INTO[dbo].[giftListGroup] (giftListFK, groupFK, updateTimestamp, updatePersonFK)
                    VALUES(@giftListFK, @groupFK, getdate(), @updatePersonFK );SELECT CAST(scope_identity() AS int)";
                List<SqlParameter> prms = new List<SqlParameter>();

                var param1 = new SqlParameter
                {
                    ParameterName = "@giftListFK",
                    Value = giftListGroup.giftListFK
                };
                prms.Add(param1);

                var param2 = new SqlParameter
                {
                    ParameterName = "@groupFK",
                    Value = giftListGroup.groupFK
                };
                prms.Add(param2);

                var param3 = new SqlParameter
                {
                    ParameterName = "@updatePersonFK",
                    Value = giftListGroup.updatePersonFK
                };
                prms.Add(param3);

                try
                {
                    return int.Parse(_conn.ExecuteScalar(sql,prms).ToString());
                }
                catch (Exception)
                {
                    throw new Exception($"Entity {giftListGroup.giftListFK} {giftListGroup.groupFK} not inserted in database!");
                }

            }
        }
コード例 #16
0
 public ItemCommentEntity GetItemCommentByItem(int itemId)
 {
     using (Connection conn = new Connection())
     {
         return GetItemCommentById(itemId, conn);
     }
 }
コード例 #17
0
        public void Update(List<GiftListGroupEntity> batch)
        {
            using (Connection conn = new Connection())
            {
                conn.BeginTransaction();
                try
                {

                }
                catch (Exception e)
                {
                    conn.RollbackTransaction();
                    throw e;
                }
                conn.CommitTransaction();
            }
        }
コード例 #18
0
 public void Update(int id, GiftListGroupEntity giftListGroup)
 {
     using (Connection conn = new Connection())
     {
         Update(id, giftListGroup, conn);
     }
 }
コード例 #19
0
 public void Insert(List<GiftListGroupEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         conn.BeginTransaction();
         try {
             batch.ForEach(x => Insert(x, conn));
         } catch(Exception e)
         {
             conn.RollbackTransaction();
             throw e;
         }
         conn.CommitTransaction();
     }
 }
コード例 #20
0
 public long Insert(ItemCommentEntity itemComment)
 {
     using (Connection conn = new Connection())
     {
         return Insert(itemComment, conn);
     }
 }
コード例 #21
0
 public GroupMemberEntity GetGroupMember(int group, int member)
 {
     using (Connection conn = new Connection())
     {
         return GetGroupMember(group, member, conn);
     }
 }
コード例 #22
0
 public long Insert(GiftListGroupEntity giftListGroup)
 {
     using (Connection conn = new Connection())
     {
         return Insert(giftListGroup, conn);
     }
 }
コード例 #23
0
 public long GetNumberOfItemComments(int item)
 {
     using (Connection conn = new Connection())
     {
         return GetNumberOfItemComments(item, conn);
     }
 }
コード例 #24
0
 public GroupMemberEntity GetGroupMemberById(int id)
 {
     using (Connection conn = new Connection())
     {
         return GetGroupMemberById(id, conn);
     }
 }
コード例 #25
0
 public void Insert(List<ItemCommentEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Insert(batch, conn);
     }
 }
コード例 #26
0
 public long GetNumberOfGroupMembers(int group)
 {
     using (Connection conn = new Connection())
     {
         return GetNumberOfGroupMembers(group, conn);
     }
 }
コード例 #27
0
 public void Update(List<ItemCommentEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Update(batch, conn);
     }
 }
コード例 #28
0
 public long Insert(GroupMemberEntity groupMember)
 {
     using (Connection conn = new Connection())
     {
         return Insert(groupMember, conn);
     }
 }
コード例 #29
0
 public bool GroupMemberExists(int group, int member)
 {
     using (Connection conn = new Connection())
     {
         return GroupMemberExists(group, member, conn);
     }
 }
コード例 #30
0
 public GiftListGroupEntity GetGiftListGroupById(int id)
 {
     using (Connection conn = new Connection())
     {
         return GetGiftListGroupById(id, conn);
     }
 }