public MerchantViewModel Convert(MerchantModel model, WeChatModels::ApplyProtocolWxResponse apply_protocol) { var viewModel = new MerchantViewModel(); viewModel.Merchant = model; var idx = 0; (model.Address ?? "").Split('/').Select((name) => { switch (idx) { case 0: viewModel.Province = name; break; case 1: viewModel.City = name; break; case 2: viewModel.Area = name; break; } idx++; return(name); }).ToList(); viewModel.OwnerId = model.EnjoyUser.Id; viewModel.ApplyProtocol = apply_protocol; viewModel.StartTimeString = model.BeginTime.ToDateTimeFromUnixStamp().ToString("yyyy-MM-dd"); viewModel.EndTimeString = model.EndTime.ToDateTimeFromUnixStamp().ToString("yyyy-MM-dd"); viewModel.Status = model.Status; return(viewModel); }
public IEnumerable <SelectNodeViewModel> Convert(WeChatModels::ApplyProtocolWxResponse response) { return(response.Categories.Select((ctx) => { return new SelectNodeViewModel() { Id = ctx.PrimaryCategoryId.ToString(), Text = ctx.CategoryName, Items = ctx.SecondaryCategories.Select((child) => { return new SelectNodeViewModel() { Id = child.SecondaryCategoryId.ToString(), Text = child.CategoryName, Items = new SelectNodeViewModel[] { } }; }).ToArray() }; })); }