Esempio n. 1
0
 public int Delete <T>(Expression <Func <T, bool> > predicate) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         var dbEntry = dbContext.Set <T>().SingleOrDefault(predicate);
         if (dbEntry != null)
         {
             dbContext.Set <T>().Remove(dbEntry);
             return(dbContext.SaveChanges());
         }
     }
     return(0);
 }
Esempio n. 2
0
 public bool CheckTypeid <T>(Expression <Func <T, bool> > wherelambda) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <T>().Where(wherelambda).Count() > 0);
     }
 }
Esempio n. 3
0
 public T GetById <T>(Expression <Func <T, bool> > wherelambda) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <T>().Where(wherelambda).FirstOrDefault());
     }
 }
Esempio n. 4
0
 public IEnumerable <TEntity> GetAll()
 {
     using (var dbContext = new DuPont_TestContext())
     {
         return(dbContext.Set <TEntity>().ToList());
     }
 }
Esempio n. 5
0
 public int Add <T>(List <T> entity) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         dbContext.Set <T>().AddRange(entity);
         return(dbContext.SaveChanges());
     }
 }
Esempio n. 6
0
 public int Modify <T>(T entity, Expression <Func <T, bool> > wherelambda) where T : class
 {
     using (var dbContext = new DuPont_TestContext())
     {
         var dbEntry = dbContext.Set <T>().Where(wherelambda).FirstOrDefault();
         if (dbEntry != null)
         {
             ClassValueCopyHelper.Copy(dbEntry, entity);
             return(dbContext.SaveChanges());
         }
     }
     return(0);
 }
        /// <summary>
        /// 产业商的需求列表
        /// </summary>
        /// <author>ww</author>
        /// <returns></returns>
        public List <PublishedModel> GetBusinessDemandList(int pageindex, int pagesize, int isclosed, out long TotalNums)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                //产业商的需求
                List <PublishedModel> list = new List <PublishedModel>();
                //我的发布--进行中
                if (isclosed == 0)
                {
                    TotalNums = (from bpd in dbContext.T_BUSINESS_PUBLISHED_DEMAND
                                 where bpd.IsDeleted == false &&
                                 (bpd.PublishStateId == 100501 ||
                                  bpd.PublishStateId == 100502 ||
                                  bpd.PublishStateId == 100503
                                 )
                                 select bpd.Id).Count();

                    list = (from bpd in dbContext.T_BUSINESS_PUBLISHED_DEMAND
                            where bpd.IsDeleted == false &&
                            (bpd.PublishStateId == 100501 ||
                             bpd.PublishStateId == 100502 ||
                             bpd.PublishStateId == 100503
                            )
                            orderby bpd.CreateTime ascending
                            select bpd)
                           .Skip((pageindex - 1) * pagesize).Take(pagesize)
                           .ToList()
                           .Select(
                        model => new PublishedModel
                    {
                        Name = "",            //dbContext.Set<T_USER>().Where(u => u.Id == model.CreateUserId).FirstOrDefault().UserName != null ? dbContext.Set<T_USER>().Where(u => u.Id == model.CreateUserId).FirstOrDefault().UserName : "",
                        Id   = model.Id,
                        RequirementTypeId  = model.DemandTypeId,
                        RequirementType    = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.DemandTypeId).FirstOrDefault()),
                        Remark             = model.Brief ?? "",
                        PublishedDate      = Utility.TimeHelper.GetMilliSeconds(model.CreateTime),
                        Dates              = model.ExpectedDate != null ? model.ExpectedDate : "",
                        AddressCode        = model.Province + "|" + model.City + "|" + model.Region + "|" + model.Township + "|" + model.Village,
                        Address            = GetAreaName(model.Province) + "" + GetAreaName(model.City) + "" + GetAreaName(model.Region) + "" + GetAreaName(model.Township) + "" + GetAreaName(model.Village),
                        DetailAddress      = model.DetailedAddress ?? "",
                        PhoneNumber        = model.PhoneNumber,
                        PublishStateId     = model.PublishStateId,
                        PublishState       = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()),
                        ExpectedStartPrice = Convert.ToDouble(model.ExpectedStartPrice),
                        ExpectedEndPrice   = Convert.ToDouble(model.ExpectedEndPrice),
                        PurchaseWeight     = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.AcquisitionWeightRangeTypeId).FirstOrDefault()),
                        PurchaseWeightId   = model.AcquisitionWeightRangeTypeId,
                        CommenceWeight     = "",
                        CommenceWeightId   = model.FirstWeight,
                        Acreage            = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.FirstWeight).FirstOrDefault()),
                        AcreageId          = 0,
                        Crop     = "",
                        CropId   = 0,
                        Credit   = 0,
                        Distance = 0,
                        Lat      = "0",
                        Lng      = "0"
                    }).ToList();

                    return(list);
                }
                else
                {
                    TotalNums = 0;
                    list      = null;
                }
                return(list);
            }
        }
        /// <summary>
        /// 大农户我的发布
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="IsClosed"></param>
        /// <param name="roletype"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="TotalNums"></param>
        /// <returns></returns>
        public List <PublishedModel> GetFarmerPublishedRequirement(long userid, int IsClosed, int roletype, int PageIndex, int PageSize, out long TotalNums)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                //我的发布--进行中 //ww增加大农户已评价100507、农机手已评价100508

                if (IsClosed == 0)
                {
                    TotalNums = (from fpd in dbContext.T_FARMER_PUBLISHED_DEMAND
                                 where fpd.CreateUserId == userid &&
                                 (
                                     fpd.PublishStateId == 100501 ||
                                     fpd.PublishStateId == 100502 ||
                                     fpd.PublishStateId == 100507 ||
                                     fpd.PublishStateId == 100508
                                 )
                                 select fpd.Id).Count();

                    var myPublishedList = (from fpd in dbContext.T_FARMER_PUBLISHED_DEMAND
                                           where fpd.CreateUserId == userid &&
                                           (
                                               fpd.PublishStateId == 100501 ||
                                               fpd.PublishStateId == 100502 ||
                                               fpd.PublishStateId == 100507 ||
                                               fpd.PublishStateId == 100508
                                           )
                                           orderby fpd.CreateTime descending
                                           select fpd)
                                          .Skip((PageIndex - 1) * PageSize).Take(PageSize)
                                          .ToList()
                                          .Select(
                        model =>
                    {
                        var item = new PublishedModel
                        {
                            Name = getUserName(dbContext.Set <T_USER>().Where(u => u.Id == model.CreateUserId).FirstOrDefault()),
                            Id   = model.Id,
                            RequirementTypeId = model.DemandTypeId,
                            RequirementType   = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.DemandTypeId).FirstOrDefault()),
                            Remark            = model.Brief ?? "",
                            Dates             = model.ExpectedDate ?? "",
                            PublishedDate     = Utility.TimeHelper.GetMilliSeconds(model.CreateTime),

                            AddressCode = model.Province + "|" + model.City + "|" + model.Region + "|" + model.Township + "|" + model.Village,

                            Address       = GetAreaName(model.Province) + "" + GetAreaName(model.City) + "" + GetAreaName(model.Region) + "" + GetAreaName(model.Township) + "" + GetAreaName(model.Village),
                            DetailAddress = model.DetailedAddress ?? "",

                            PhoneNumber        = model.PhoneNumber,
                            PublishStateId     = model.PublishStateId,
                            PublishState       = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()),
                            ExpectedStartPrice = Convert.ToDouble(model.ExpectedStartPrice),
                            ExpectedEndPrice   = Convert.ToDouble(model.ExpectedEndPrice),
                            Acreage            = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()),
                            AcreageId          = model.AcresId,
                            Crop             = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.CropId).FirstOrDefault()),
                            CropId           = model.CropId,
                            CommenceWeightId = 0,
                            CommenceWeight   = "",
                            PurchaseWeightId = 0,
                            PurchaseWeight   = "",
                            Credit           = 0,
                            Distance         = 0,
                            Lat = "0",
                            Lng = "0"
                        };
                        return(item);
                    }).ToList();

                    return(myPublishedList);
                }
                //我的发布--已关闭
                else if (IsClosed != 0)
                {
                    TotalNums = (from fpd in dbContext.T_FARMER_PUBLISHED_DEMAND
                                 join fdrr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION on fpd.Id equals fdrr.DemandId into joined_fdrr_fpt
                                 from fdrr in joined_fdrr_fpt.DefaultIfEmpty()
                                 where fpd.CreateUserId == userid &&
                                 (
                                     fpd.PublishStateId == 100503 ||
                                     fpd.PublishStateId == 100504 ||
                                     fpd.PublishStateId == 100505 ||
                                     fpd.PublishStateId == 100506
                                     //|| fdrr.Score > 0
                                     //|| fdrr.Comments != null ww 有状态值判断了,没必要用评价农机手内容和几级来判断了
                                 )
                                 select fpd.Id).Count();

                    var myPublishedList = (from fpd in dbContext.T_FARMER_PUBLISHED_DEMAND
                                           join fdrr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION on fpd.Id equals fdrr.DemandId into joined_fdrr_fpt
                                           from fdrr in joined_fdrr_fpt.DefaultIfEmpty()
                                           where fpd.CreateUserId == userid &&
                                           (
                                               fpd.PublishStateId == 100503 ||
                                               fpd.PublishStateId == 100504 ||
                                               fpd.PublishStateId == 100505 ||
                                               fpd.PublishStateId == 100506
                                               //|| fdrr.Score > 0
                                               //|| fdrr.Comments != null ww 有状态值判断了,没必要用评价农机手内容和几级来判断了
                                           )
                                           orderby fpd.CreateTime descending
                                           select fpd)
                                          .Skip((PageIndex - 1) * PageSize).Take(PageSize)
                                          .ToList()
                                          .Select(
                        model =>
                    {
                        var item = new PublishedModel
                        {
                            Name = getUserName(dbContext.Set <T_USER>().Where(u => u.Id == model.CreateUserId).FirstOrDefault()),
                            Id   = model.Id,
                            RequirementTypeId = model.DemandTypeId,
                            RequirementType   = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.DemandTypeId).FirstOrDefault()),
                            Remark            = model.Brief ?? "",
                            Dates             = model.ExpectedDate ?? "",
                            PublishedDate     = Utility.TimeHelper.GetMilliSeconds(model.CreateTime),

                            AddressCode = model.Province + "|" + model.City + "|" + model.Region + "|" + model.Township + "|" + model.Village,

                            Address       = GetAreaName(model.Province) + "" + GetAreaName(model.City) + "" + GetAreaName(model.Region) + "" + GetAreaName(model.Township) + "" + GetAreaName(model.Village),
                            DetailAddress = model.DetailedAddress ?? "",

                            PhoneNumber        = model.PhoneNumber,
                            PublishStateId     = model.PublishStateId,
                            PublishState       = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()),
                            ExpectedStartPrice = Convert.ToDouble(model.ExpectedStartPrice),
                            ExpectedEndPrice   = Convert.ToDouble(model.ExpectedEndPrice),
                            Acreage            = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()),
                            AcreageId          = model.AcresId,
                            Crop             = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.CropId).FirstOrDefault()),
                            CropId           = model.CropId,
                            CommenceWeightId = 0,
                            CommenceWeight   = "",
                            PurchaseWeightId = 0,
                            PurchaseWeight   = "",
                            Credit           = 0,
                            Distance         = 0,
                            Lat = "0",
                            Lng = "0"
                        };
                        return(item);
                    }).ToList();

                    return(myPublishedList);
                }

                TotalNums = 0;
                return(null);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 农机手我的应答列表
        /// </summary>
        /// <param name="ReceiveRoleId">应答人的角色编号</param>
        /// <author>ww</author>
        /// <returns></returns>
        public List <CommonReplyModel> GetOperatorReplayList(int ReceiveRoleId, int pageindex, int pagesize, int isclosed, long userid, out long TotalNums)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                //应答列表中的地址是大农户发布需求时的地址
                List <CommonReplyModel> list = new List <CommonReplyModel>();
                //进行中
                if (isclosed == 0)
                {
                    TotalNums = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION
                                 join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id
                                 where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200
                                 &&
                                 (fpd.PublishStateId == 100502 ||
                                  fpd.PublishStateId == 100507 ||
                                  fpd.PublishStateId == 100508
                                 )
                                 select drr.Id).Count();

                    if (TotalNums == 0)
                    {
                        return(null);
                    }

                    list = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION
                            join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id
                            join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code
                            join user in dbContext.T_USER on fpd.CreateUserId equals user.Id
                            where drr.UserId == userid && fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 &&
                            (fpd.PublishStateId == 100502 ||
                             fpd.PublishStateId == 100507 ||
                             fpd.PublishStateId == 100508
                            )
                            orderby drr.CreateTime descending
                            select new
                    {
                        drr.Id,
                        fpd.DemandTypeId,
                        fpd.CreateTime,
                        fpd.Province,
                        fpd.City,
                        fpd.Region,
                        fpd.Township,
                        fpd.Village,
                        fpd.DetailedAddress,
                        fpd.PhoneNumber,
                        fpd.Brief,
                        fpd.PublishStateId,
                        fpd.AcresId,
                        user.UserName,
                        fpd.CreateUserId,
                        DemandTypeName = dic.DisplayName
                    }).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList()
                           .Select(
                        model =>
                    {
                        var item = new CommonReplyModel
                        {
                            Id = model.Id,
                            RequirementType = model.DemandTypeName,
                            PublishedDate   = Utility.TimeHelper.GetMilliSeconds(model.CreateTime),
                            Address         = GetAreaName(model.Province)
                                              + GetAreaName(model.City)
                                              + GetAreaName(model.Region)
                                              + GetAreaName(model.Township)
                                              + GetAreaName(model.Village),
                            DetailAddress     = model.DetailedAddress ?? "",
                            PhoneNumber       = model.PhoneNumber,
                            Remark            = model.Brief ?? "",
                            PublishState      = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()),
                            Acreage           = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()),
                            PublisherUserName = model.UserName,
                            RoleId            = (int)RoleType.Farmer,
                            RoleName          = RoleType.Farmer.GetDescription(),
                            PublisherUserId   = model.CreateUserId,
                            RequirementTypeId = model.DemandTypeId,
                            PublishStateId    = model.PublishStateId,
                            ReceiveRoleId     = ReceiveRoleId
                        };
                        return(item);
                    }).ToList();
                }
                else if (isclosed != 0)//已关闭
                {
                    TotalNums = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION
                                 join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id
                                 join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code
                                 where drr.UserId == userid &&
                                 fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 &&
                                 (
                                     fpd.PublishStateId == 100503 ||
                                     fpd.PublishStateId == 100504 ||
                                     fpd.PublishStateId == 100505 ||
                                     fpd.PublishStateId == 100506
                                 )
                                 select drr.Id).Count();

                    if (TotalNums == 0)
                    {
                        return(null);
                    }

                    list = (from drr in dbContext.T_FARMER_DEMAND_RESPONSE_RELATION
                            join fpd in dbContext.T_FARMER_PUBLISHED_DEMAND on drr.DemandId equals fpd.Id
                            join dic in dbContext.T_SYS_DICTIONARY on fpd.DemandTypeId equals dic.Code
                            join user in dbContext.T_USER on fpd.CreateUserId equals user.Id
                            where drr.UserId == userid &&
                            fpd.DemandTypeId > 100100 && fpd.DemandTypeId < 100200 &&
                            (
                                fpd.PublishStateId == 100503 ||
                                fpd.PublishStateId == 100504 ||
                                fpd.PublishStateId == 100505 ||
                                fpd.PublishStateId == 100506
                            )
                            orderby drr.CreateTime descending
                            select new
                    {
                        drr.Id,
                        fpd.DemandTypeId,
                        fpd.CreateTime,
                        fpd.Province,
                        fpd.City,
                        fpd.Region,
                        fpd.Township,
                        fpd.Village,
                        fpd.DetailedAddress,
                        fpd.PhoneNumber,
                        fpd.Brief,
                        fpd.PublishStateId,
                        fpd.AcresId,
                        user.UserName,
                        fpd.CreateUserId,
                        DemandTypeName = dic.DisplayName
                    }).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList()
                           .Select(
                        model =>
                    {
                        var item = new CommonReplyModel
                        {
                            Id = model.Id,
                            RequirementType = model.DemandTypeName,
                            PublishedDate   = Utility.TimeHelper.GetMilliSeconds(model.CreateTime),
                            Address         = GetAreaName(model.Province)
                                              + GetAreaName(model.City)
                                              + GetAreaName(model.Region)
                                              + GetAreaName(model.Township)
                                              + GetAreaName(model.Village),
                            DetailAddress     = model.DetailedAddress ?? "",
                            PhoneNumber       = model.PhoneNumber,
                            Remark            = model.Brief ?? "",
                            PublishState      = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == model.PublishStateId).FirstOrDefault()),
                            Acreage           = getDisplayName(dbContext.T_SYS_DICTIONARY.Where(dic => dic.Code == model.AcresId).FirstOrDefault()),
                            PublisherUserName = model.UserName,
                            RoleId            = (int)RoleType.Farmer,
                            RoleName          = RoleType.Farmer.GetDescription(),
                            PublisherUserId   = model.CreateUserId,
                            RequirementTypeId = model.DemandTypeId,
                            PublishStateId    = model.PublishStateId,
                            ReceiveRoleId     = ReceiveRoleId
                        };
                        return(item);
                    }).ToList();
                }
                else
                {
                    TotalNums = 0;
                    list      = null;
                }
                return(list);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 应答详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BusinessReplyDetailModel GetReplyDetail(long id)
        {
            using (var dbContext = new DuPont_TestContext())
            {
                //农机手应答详情包括订单详情和应答详情,订单详情中的地址是大农户发布需求的地址,应答详情中的地址是农机手注册时的地址
                var rmodel = dbContext.Set <T_FARMER_DEMAND_RESPONSE_RELATION>().Where(b => b.Id == id).FirstOrDefault();
                if (rmodel != null)
                {
                    T_FARMER_PUBLISHED_DEMAND tmodel = dbContext.Set <T_FARMER_PUBLISHED_DEMAND>().Where(f => f.Id == rmodel.DemandId).FirstOrDefault();
                    if (tmodel != null)
                    {
                        var    type       = dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == tmodel.DemandTypeId).FirstOrDefault();
                        string typestring = type != null ? type.DisplayName : "";

                        var    publishstate       = dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == tmodel.PublishStateId).FirstOrDefault();
                        string publishstatestring = publishstate != null ? publishstate.DisplayName : "";

                        var    name       = dbContext.Set <T_USER>().Where(u => u.Id == tmodel.CreateUserId).FirstOrDefault();
                        string namestring = name != null ? name.UserName != null ? name.UserName : "" : "";

                        var  level       = dbContext.Set <T_USER_ROLE_RELATION>().Where(u => u.MemberType && u.UserID == tmodel.CreateUserId).FirstOrDefault();
                        long?levelstring = level != null ? level.Star : 0;

                        var    crops      = dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == tmodel.CropId).FirstOrDefault();
                        string cropstring = crops != null ? crops.DisplayName : "";

                        string replynamestring  = "";
                        string addressstring    = "";
                        string replyphonenumber = "";
                        var    replymodel       = dbContext.Set <T_USER>().Where(u => u.Id == rmodel.UserId).FirstOrDefault();
                        if (replymodel != null)
                        {
                            replynamestring  = replymodel.UserName != null ? replymodel.UserName : "";
                            addressstring    = GetAreaName(replymodel.Province) + GetAreaName(replymodel.City) + GetAreaName(replymodel.Region) + GetAreaName(replymodel.Township) + GetAreaName(replymodel.Village);
                            replyphonenumber = replymodel.PhoneNumber;
                        }
                        BusinessReplyDetailModel model = new BusinessReplyDetailModel()
                        {
                            UserName           = namestring,
                            UserLevel          = levelstring,
                            Id                 = tmodel.Id,
                            CropId             = tmodel.CropId,
                            Crop               = cropstring,
                            TypeId             = tmodel.DemandTypeId,
                            Type               = typestring,
                            AcreageId          = tmodel.AcresId,
                            Acreage            = getDisplayName(dbContext.Set <T_SYS_DICTIONARY>().Where(s => s.Code == tmodel.AcresId).FirstOrDefault()),
                            Remark             = tmodel.Brief != null ? tmodel.Brief : "",
                            Dates              = StringHelper.TransfeDate(tmodel.ExpectedDate),
                            PublishedDate      = Utility.TimeHelper.GetMilliSeconds(tmodel.CreateTime),
                            Address            = GetAreaName(tmodel.Province) + "" + GetAreaName(tmodel.City) + "" + GetAreaName(tmodel.Region) + "" + GetAreaName(tmodel.Township) + "" + GetAreaName(tmodel.Village),
                            DetailAddress      = tmodel.DetailedAddress != null ? tmodel.DetailedAddress : "",
                            PhoneNumber        = tmodel.PhoneNumber,
                            ExpectedStartPrice = Convert.ToDouble(tmodel.ExpectedStartPrice),
                            ExpectedEndPrice   = Convert.ToDouble(tmodel.ExpectedEndPrice),
                            PublishStateId     = tmodel.PublishStateId,
                            PublishState       = publishstatestring,

                            ReplyUserId          = rmodel.UserId,
                            ReplyUserName        = replynamestring,
                            ReplyPhoneNumber     = replyphonenumber,
                            ReplyDetailedAddress = addressstring,
                            ReplyTime            = Utility.TimeHelper.GetMilliSeconds(rmodel.CreateTime),
                            ReplyRemark          = "",
                            Score             = rmodel.Score,
                            UserId            = tmodel.CreateUserId,
                            PublisherRoleId   = (int)RoleType.Farmer,
                            PublisherRoleName = RoleType.Farmer.GetDescription()
                        };
                        return(model);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }