protected override object CreateListModel(IPagedList <ScheduleTask> source, int pageSize) { List <ScheduleTaskViewModel> result = new List <ScheduleTaskViewModel>(); foreach (ScheduleTask item in source) { ScheduleTaskViewModel listModel = new ScheduleTaskViewModel(); WebTools.CopyProperties(item, listModel); listModel.EnabledString = item.Enabled.ToString(); listModel.StopOnErrorString = item.StopOnError.ToString(); listModel.LastEndTime = item.LastEndUtc != null?item.LastEndUtc.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") : ""; listModel.LastStartTime = item.LastStartUtc != null?item.LastStartUtc.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") : ""; listModel.LastSuccessTime = item.LastSuccessUtc != null?item.LastSuccessUtc.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") : ""; result.Add(listModel); } var gridModel = new DataSourceResult <ScheduleTaskViewModel>(pageSize) { Data = result, Total = source.TotalCount, PageCount = source.TotalPages }; return(gridModel); }
public ActionResult Version(VersionSettingModel model) { VersionSetting entity = new VersionSetting(); WebTools.CopyProperties(model, entity); entity.Mandatory = model.MandatoryStr == "on"; _settingService.SaveSetting(entity, v => v.VersionCode, false); _settingService.SaveSetting(entity, v => v.VersionName, false); _settingService.SaveSetting(entity, v => v.UpdateTime, false); _settingService.SaveSetting(entity, v => v.IosDownloadUrl, false); _settingService.SaveSetting(entity, v => v.Mandatory, false); _settingService.SaveSetting(entity, v => v.DownloadUrl, false); _settingService.SaveSetting(entity, v => v.Description, false); _settingService.ClearCache(); return(Ok()); }
public virtual ActionResult Get(int id) { if (0 == id) { return(new BadResponse("参数错误")); } E entity = EntityService.GetById(id, true); if (null == entity) { return(new BadResponse("参数错误")); } M model = Activator.CreateInstance <M>(); WebTools.CopyProperties(entity, model); FillOtherInfo(model, entity); return(new JsonResult() { Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public virtual ActionResult Put(FormCollection form) { M model = Activator.CreateInstance <M>(); updateModel(model, form); if (0 == model.Id) { E entity = Activator.CreateInstance <E>(); WebTools.CopyProperties(model, entity); var otherOk = ProcessPutOtherThing(model, entity); if (otherOk.Successfully) { EntityService.Insert(entity); } else { return(new BadResponse(otherOk.ErrorMessage)); } } else { var entity = EntityService.GetById(model.Id, false); if (null == entity) { return(new BadResponse("参数错误")); } WebTools.CopyProperties(model, entity, false); var otherOk = ProcessPutOtherThing(model, entity); if (otherOk.Successfully) { EntityService.Update(entity); } else { return(new BadResponse(otherOk.ErrorMessage)); } } return(new ContentResult()); }