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

来源:互联网 发布:中国债务危机 知乎 编辑:程序博客网 时间:2024/05/26 09:54

今天遇到两个问题

第一,页面点击只执行部分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
原创粉丝点击