关于js的加载顺序及Asp.net MVC中list问题

今天遇到两个问题

第一,页面点击只执行部分js代码,调试了很多次,最后才发现js加载顺序弄错了,应该把js放在最后面加载的。所以以后要注意javascript的加载顺序

第二,关于MVC中通过接口获取了数据 ,然后将其放入Model中,这个一般方法是这样的

①取出的数据为list

public ActionResult IndustryList()
{

      var servicerList = _customerService.GetAllServicers(0, 7,10);//通过接口取出数据为list
var model = new List<ServicerModel>();//new 出个list model来接收数据
if (servicerList != null && servicerList.Count > 0)
{
model.AddRange(servicerList.Select(x =>
{
var mod = new ServicerModel();
mod.Name = x.User.Company;
mod.Id = x.Id;
mod.ImgUrl = _pictureService.GetPictureUrl(Convert.ToInt32(x.User.LogoId));
mod.ServicerProjects = "";
var projects = x.ServerScopes;
if (projects != null && projects.Count > 0)
{
foreach (var item in projects)
{
mod.ServicerProjects += item.Name + " ";
}
}
mod.CaseCount = x.SuccessfulCaseCounts;
mod.QualificationCount = x.QualificationCounts;
mod.DesignerCount = x.DesignerCounts;
mod.CommentCount = x.CustomerRatingCounts;
var couponList = x.CouponEntities;
if (couponList != null && couponList.Count > 0)
{
mod.CouponList = couponList.Select(m =>
{
var mod2 = new CouponModel();
mod2.CouponName = m.Name;
mod2.Id = m.Id;
mod2.FaceValue = m.FaceValue;
return mod2;
}).ToList();
}
return mod;
}).ToList());
}


return PartialView(model);

}


②取出的数据为一组

public ActionResult MExhibitionMettingInfo(int id)
{
var metting = _meetingService.GetMeetingById(id);


var meetMod = new MeetingModel();
if (metting != null)
{
meetMod.MeetId = metting.Id;
meetMod.ExhibitionId = metting.ExhibitionId.ToInt();
meetMod.Name = metting.Name;
meetMod.Address = metting.Address;
meetMod.OrganizeInstitution = metting.OrganizeInstitution;
meetMod.TotalNum = metting.TotalNumber;
meetMod.FullDescription = metting.FullDescription;
meetMod.StartedDataTime = metting.StartedOnUtc.ToLocalTime().ToString("yyyy-MM-dd HH:mm");
meetMod.EndedDateTime = metting.EndedOnUtc.ToLocalTime().ToString("yyyy-MM-dd HH:mm");
if (metting.PosterPicture != null)
{
meetMod.BigPictureUrl = _pictureService.GetPictureUrl(metting.PosterPicture.Id);
}
meetMod.SmallPictureUrl = meetMod.BigPictureUrl;
}


return View(meetMod);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值