コード例 #1
0
        public static async Task <IEnumerable <MyZeroActivityApplications> > SelectMyApplicationsAsync(Guid userId, int applicationStatus)
        {
            using (var cmd = new SqlCommand(SelectMyApplications))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@UserID", userId);
                cmd.Parameters.AddWithValue("@ApplicationStatus", applicationStatus);

                return(await DbHelper.ExecuteSelectAsync <MyZeroActivityApplications>(!(await RedisHelper.GetZeroActivityApplyCacheOnUserId(userId)), cmd));
            }
        }
コード例 #2
0
 public static async Task <bool> HasZeroActivityApplicationSubmittedAsync(Guid userId, int period)
 {
     using (var cmd = new SqlCommand(NumOfZeroActivityApplications))
     {
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.AddWithValue("@UserID", userId);
         cmd.Parameters.AddWithValue("@Period", period);
         return(Convert.ToInt32(await DbHelper.ExecuteScalarAsync(!(await RedisHelper.GetZeroActivityApplyCacheOnPeriod(period)) || !(await RedisHelper.GetZeroActivityApplyCacheOnUserId(userId)), cmd)) > 0);
     }
 }
コード例 #3
0
        public static async Task <SelectedTestReportDetail> FetchTestReportDetailAsync(int commentId)
        {
            using (var cmd = new SqlCommand(FetchTestReportDetail))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@CommentId", commentId);
                return(await DbHelper.ExecuteQueryAsync(!(await RedisHelper.GetZeroActivityApplyCache()), cmd, (dt) =>
                {
                    if (dt?.Rows?.OfType <DataRow>() == null || !dt.Rows.OfType <DataRow>().Any())
                    {
                        return null;
                    }
                    var dr = dt.Rows.OfType <DataRow>().First();
                    var result = new SelectedTestReportDetail();

                    result.CommentId = Convert.ToInt32(dr["CommentId"]);
                    if (!(dr["UserID"] is DBNull))
                    {
                        result.UserId = Guid.Parse(dr["UserID"].ToString());
                    }
                    result.ReportTitle = dr["SingleTitle"]?.ToString();
                    result.ReportContent = dr["CommentContent"]?.ToString();
                    result.ReportAbstract = (result.ReportContent != null && result.ReportContent.Length > 100)
                                            ? result.ReportContent.Substring(0, 100) : result.ReportContent;
                    if (!(dr["CreateTime"] is DBNull))
                    {
                        result.ReportCreateTime = Convert.ToDateTime(dr["CreateTime"]);
                    }
                    if (!(dr["Period"] is DBNull))
                    {
                        result.Period = Convert.ToInt32(dr["Period"]);
                    }
                    result.ProvinceID = Convert.ToInt32(dr["ProvinceID"]);
                    result.CityID = Convert.ToInt32(dr["CityID"]);
                    if (!(dr["UpdateTime"] is DBNull))
                    {
                        result.ReportUpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
                    }
                    result.ProductId = dr["CommentProductId"]?.ToString();
                    result.ProductFamilyId = dr["CommentProductFamilyId"]?.ToString();
                    if (!(dr["CommentOrderId"] is DBNull))
                    {
                        result.OrderId = Convert.ToInt32(dr["CommentOrderId"]);
                    }
                    if (!(dr["CommentOrderListId"] is DBNull))
                    {
                        result.OrderListId = Convert.ToInt32(dr["CommentOrderListId"]);
                    }
                    if (!(dr["CommentStatus"] is DBNull))
                    {
                        result.CommentStatus = Convert.ToInt32(dr["CommentStatus"]);
                    }
                    if (!(dr["ReportStatus"] is DBNull))
                    {
                        result.ReportStatus = Convert.ToInt32(dr["ReportStatus"]);
                    }
                    result.OfficialReply = dr["OfficialReply"]?.ToString();
                    if (!(dr["CommentR1"] is DBNull))
                    {
                        result.Comfortability = Convert.ToInt32(dr["CommentR1"]);
                    }
                    if (!(dr["CommentR2"] is DBNull))
                    {
                        result.MutePerformance = Convert.ToInt32(dr["CommentR2"]);
                    }
                    if (!(dr["CommentR3"] is DBNull))
                    {
                        result.Controllability = Convert.ToInt32(dr["CommentR3"]);
                    }
                    if (!(dr["CommentR4"] is DBNull))
                    {
                        result.AbrasionPerformance = Convert.ToInt32(dr["CommentR4"]);
                    }
                    if (!(dr["CommentR5"] is DBNull))
                    {
                        result.OilSaving = Convert.ToInt32(dr["CommentR5"]);
                    }
                    if (!(dr["CommentR6"] is DBNull))
                    {
                        result.CustomServiceSatisfaction = Convert.ToInt32(dr["CommentR6"]);
                    }
                    if (!(dr["CommentR7"] is DBNull))
                    {
                        result.ShopSatisfaction = Convert.ToInt32(dr["CommentR7"]);
                    }
                    if (!(dr["CommentImages"] is DBNull) && !string.IsNullOrWhiteSpace(dr["CommentImages"].ToString()))
                    {
                        result.ReportImages = dr["CommentImages"].ToString().Split(';');
                    }
                    if (!(dr["CommentExtAttr"] is DBNull) && !string.IsNullOrWhiteSpace(dr["CommentExtAttr"].ToString()))
                    {
                        result.TestReportExtenstionAttribute = JsonConvert.DeserializeObject <CommentExtenstionAttribute>(dr["CommentExtAttr"].ToString());
                    }
                    return result;
                }));
            }
        }