Exemple #1
0
 public IList<LinkEntity> GetAllLinks()
 {
     using (Connection conn = new Connection())
     {
         return GetAllLinks(conn);
     }
 }
 public IList<ItemCommentEntity> GetAllItemComments()
 {
     using (Connection conn = new Connection())
     {
         return GetAllItemComments(conn);
     }
 }
 public IList<PersonEntity> GetAllPersons()
 {
     using (Connection conn = new Connection())
     {
         return GetAllPersons(conn);
     }
 }
 public void Delete(int id)
 {
     using (Connection conn = new Connection())
     {
         Delete(id, conn);
     }
 }
 public IList<PurchaseEntity> GetAllPurchases()
 {
     using (Connection conn = new Connection())
     {
         return GetAllPurchases(conn);
     }
 }
 public IList<GroupMemberEntity> GetAllGroupMembers()
 {
     using (Connection conn = new Connection())
     {
         return GetAllGroupMembers(conn);
     }
 }
 public void Delete(List<int> batch)
 {
     using (Connection conn = new Connection())
     {
         Delete(batch,conn);
     }
 }
 public IList<GiftListGroupEntity> GetAllGiftListGroups()
 {
     using (Connection conn = new Connection())
     {
         return GetAllGiftListGroups(conn);
     }
 }
 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();
     }
 }
 public void Update(List<GroupMemberEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Update(batch, conn);
     }
 }
 public void Update(int id, GroupMemberEntity groupMember)
 {
     using (Connection conn = new Connection())
     {
         Update(id, groupMember, conn);
     }
 }
 public void Insert(List<GroupMemberEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Insert(batch, conn);
     }
 }
 public bool GiftListGroupExists(int giftList, int group)
 {
     using (Connection conn = new Connection())
     {
         return GiftListGroupExists(giftList, group, conn);
     }
 }
 public void Update(int id, ItemCommentEntity itemComment)
 {
     using (Connection conn = new Connection())
     {
         Update(id, itemComment, conn);
     }
 }
        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!");
                }

            }
        }
 public ItemCommentEntity GetItemCommentByItem(int itemId)
 {
     using (Connection conn = new Connection())
     {
         return GetItemCommentById(itemId, conn);
     }
 }
        public void Update(List<GiftListGroupEntity> batch)
        {
            using (Connection conn = new Connection())
            {
                conn.BeginTransaction();
                try
                {

                }
                catch (Exception e)
                {
                    conn.RollbackTransaction();
                    throw e;
                }
                conn.CommitTransaction();
            }
        }
 public void Update(int id, GiftListGroupEntity giftListGroup)
 {
     using (Connection conn = new Connection())
     {
         Update(id, giftListGroup, conn);
     }
 }
 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();
     }
 }
 public long Insert(ItemCommentEntity itemComment)
 {
     using (Connection conn = new Connection())
     {
         return Insert(itemComment, conn);
     }
 }
 public GroupMemberEntity GetGroupMember(int group, int member)
 {
     using (Connection conn = new Connection())
     {
         return GetGroupMember(group, member, conn);
     }
 }
 public long Insert(GiftListGroupEntity giftListGroup)
 {
     using (Connection conn = new Connection())
     {
         return Insert(giftListGroup, conn);
     }
 }
 public long GetNumberOfItemComments(int item)
 {
     using (Connection conn = new Connection())
     {
         return GetNumberOfItemComments(item, conn);
     }
 }
 public GroupMemberEntity GetGroupMemberById(int id)
 {
     using (Connection conn = new Connection())
     {
         return GetGroupMemberById(id, conn);
     }
 }
 public void Insert(List<ItemCommentEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Insert(batch, conn);
     }
 }
 public long GetNumberOfGroupMembers(int group)
 {
     using (Connection conn = new Connection())
     {
         return GetNumberOfGroupMembers(group, conn);
     }
 }
 public void Update(List<ItemCommentEntity> batch)
 {
     using (Connection conn = new Connection())
     {
         Update(batch, conn);
     }
 }
 public long Insert(GroupMemberEntity groupMember)
 {
     using (Connection conn = new Connection())
     {
         return Insert(groupMember, conn);
     }
 }
 public bool GroupMemberExists(int group, int member)
 {
     using (Connection conn = new Connection())
     {
         return GroupMemberExists(group, member, conn);
     }
 }
 public GiftListGroupEntity GetGiftListGroupById(int id)
 {
     using (Connection conn = new Connection())
     {
         return GetGiftListGroupById(id, conn);
     }
 }