コード例 #1
0
ファイル: bn_ProductTag.cs プロジェクト: tampham47/juddy.vn
        public Guid Create(Guid hashTagId, Nullable <System.Guid> userId, string comment)
        {
            bn_HashTag bnHashTag    = new bn_HashTag();
            var        hashtag      = bnHashTag.GetById(hashTagId);
            var        productTagId = Guid.NewGuid();

            if (hashtag.Type == EHashtag_Type.System)
            {
                if (userId.HasValue && !IsExistsInUser((Guid)userId, hashTagId))
                {
                    var re = (int)db.pb_ProductTag_Create(
                        productTagId,
                        productId,
                        hashTagId,
                        userId,
                        comment).Single();

                    if (re >= 0)
                    {
                        return(productTagId);
                    }
                }
            }
            else
            {
                if (!IsExists(hashTagId))
                {
                    var re = (int)db.pb_ProductTag_Create(
                        productTagId,
                        productId,
                        hashTagId,
                        userId,
                        comment).Single();

                    if (re >= 0)
                    {
                        return(productTagId);
                    }
                }
            }

            return(Guid.Empty);
        }