コード例 #1
0
        public string GetObjectById_User(QueryCommon <IWantToBuyQuery> query)
        {
            Result_Model_List_IWantToBuy <Result_IWantToBuy> resAll = new Result_Model_List_IWantToBuy <Result_IWantToBuy>()
            {
                Model = new Result_Model <Result_IWantToBuy>(),
                Msg   = new Result_Msg()
                {
                    IsSuccess = true, Message = string.Empty
                },
                List = new Result_List <Result_Model <Result_IWantToBuy> >()
            };

            try
            {
                Result_Model <IWantToBuy> job = iWantToBuyService.GetObjectById_Web(query.ParamInfo.Id);
                var listHash = hashSet.Get_DictionariesList();

                resAll.Model.Model = new Result_IWantToBuy()
                {
                    Id          = job.Model.Id,
                    PurchaseID  = job.Model.PurchaseID,
                    ProductName = job.Model.ProductName,
                    PurchaseNum = job.Model.PurchaseNum,
                    Quantity    = job.Model.Quantity,
                    Remarks     = job.Model.Remarks == null ? string.Empty : job.Model.Remarks,
                    TotalPrice  = job.Model.TotalPrice,
                    Unit        = job.Model.Unit,
                    UnitPrice   = job.Model.UnitPrice,
                    Address     = job.Model.Address,
                    Status      = job.Model.Status,
                    StatusStr   = listHash.Where(y => y.DictionaryTypeId == 107 && y.DKey == job.Model.Status.ToString()).FirstOrDefault().DValue,

                    DeliveryDate = job.Model.DeliveryDate.ToString("yyyy-MM-dd"),
                    CreateDate   = job.Model.CreateDate.ToString("yyyy-MM-dd hh:mm"),
                    StartDate    = job.Model.StartDate.ToString("yyyy-MM-dd hh:mm"),
                    EndDate      = job.Model.EndDate.ToString("yyyy-MM-dd hh:mm"),
                    UpdateDate   = job.Model.UpdateDate.ToString("yyyy-MM-dd hh:mm"),

                    TypeOfCurrency = listHash.Where(y => y.DictionaryTypeId == 1 && y.DValue == job.Model.TypeOfCurrency.ToString()).FirstOrDefault().Remarks
                };

                if (resAll.Model != null && resAll.Msg.IsSuccess)
                {
                    resAll.List = Get_PreNext_ById_Web(query.ParamInfo.Id);
                    if (!resAll.List.Msg.IsSuccess)
                    {
                        resAll.Msg.IsSuccess = false;
                        resAll.Msg.Message  += "获取上一页、下一页失败!\n\r";
                    }
                }
            }
            catch (Exception ex)
            {
                resAll.Msg = new Result_Msg()
                {
                    IsSuccess = false, Message = "读取失败,失败原因:" + ex.Message
                };
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(resAll));
        }