Example #1
0
        /// <summary>
        /// Validates endorsement status.
        /// </summary>
        /// <param name="turnContext">Context object containing information cached for a single turn of conversation with a user.</param>
        /// <param name="valuesforTaskModule">Get the binded values from the card.</param>
        /// <returns>Returns the true, if endorsement is successful, else false.</returns>
        private async Task <bool> CheckEndorseStatusAsync(ITurnContext <IInvokeActivity> turnContext, AdaptiveCardAction valuesforTaskModule)
        {
            var teamsDetails         = turnContext.Activity.TeamsGetTeamInfo();
            var teamsChannelAccounts = await TeamsInfo.GetTeamMembersAsync(turnContext, teamsDetails.Id, CancellationToken.None);

            var userDetails   = teamsChannelAccounts.Where(member => member.AadObjectId == turnContext.Activity.From.AadObjectId).FirstOrDefault();
            var endorseEntity = await this.endorseDetailStorageProvider.GetEndorseDetailAsync(teamsDetails.Id, valuesforTaskModule.RewardCycleId, valuesforTaskModule.NominatedToPrincipalName);

            var result = endorseEntity.Where(row => row.EndorseForAwardId == valuesforTaskModule.AwardId && row.EndorsedByObjectId == userDetails.AadObjectId).FirstOrDefault();

            if (result == null)
            {
                var endorsedetails = new EndorseEntity
                {
                    TeamId                  = teamsDetails.Id,
                    EndorsedByObjectId      = userDetails.AadObjectId,
                    EndorsedByPrincipalName = userDetails.Email,
                    EndorseForAward         = valuesforTaskModule.AwardName,
                    EndorsedToPrincipalName = valuesforTaskModule.NominatedToPrincipalName,
                    EndorsedToObjectId      = valuesforTaskModule.NominatedToObjectId,
                    EndorsedOn              = DateTime.UtcNow,
                    EndorseForAwardId       = valuesforTaskModule.AwardId,
                    AwardCycle              = valuesforTaskModule.RewardCycleId,
                };

                return(await this.endorseDetailStorageProvider.StoreOrUpdateEndorseDetailAsync(endorsedetails));
            }

            return(false);
        }
        /// <summary>
        /// Store or update endorse details in Azure table storage.
        /// </summary>
        /// <param name="endorseEntity">Represents endorse entity used for storage and retrieval.</param>
        /// <returns><see cref="Task"/> that represents endorse entity is saved or updated.</returns>
        public async Task <bool> StoreOrUpdateEndorseDetailAsync(EndorseEntity endorseEntity)
        {
            await this.EnsureInitializedAsync();

            endorseEntity        = endorseEntity ?? throw new ArgumentNullException(nameof(endorseEntity));
            endorseEntity.RowKey = Guid.NewGuid().ToString();
            TableOperation addOrUpdateOperation = TableOperation.InsertOrReplace(endorseEntity);
            var            result = await this.CloudTable.ExecuteAsync(addOrUpdateOperation);

            return(result.HttpStatusCode == (int)HttpStatusCode.NoContent);
        }
Example #3
0
        public JsonResult Delete([FromForm] string token, [FromForm] int objId, [FromForm] int type)
        {
            DataResult dr = new DataResult();

            try
            {
                if (objId < 10000 || type < 1)
                {
                    dr.code = "201";
                    dr.msg  = "参数错误";
                    return(Json(dr));
                }

                UserEntity userEntity = this.GetUserByToken(token);


                EndorseBLL    endorseBLL    = new EndorseBLL();
                EndorseEntity endorseEntity = endorseBLL.GetUserIdAndTypeAndObjId(userEntity.userId, type, objId);

                endorseEntity.isDel      = true;
                endorseEntity.modifyDate = DateTime.Now;

                int rows = endorseBLL.ActionDal.ActionDBAccess.Updateable(endorseEntity).ExecuteCommand();
                //增加阅读记录
                ReadBLL readBLL = new ReadBLL();
                readBLL.Create(userEntity.userId, type, objId);
                if (rows > 0)
                {
                    dr.code = "200";
                    dr.msg  = "成功";
                }
                else
                {
                    dr.code = "201";
                    dr.msg  = "失败";
                }
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }
            return(Json(dr));
        }