/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static VirusHandleRecordDataModel ToModel(this VirusHandleRecord model) { return(new VirusHandleRecordDataModel() { Id = model.Id, Virus = model.VirusKey, HandleStatus = model.HandleStatus, Create = model.Create, IsRemoved = model.IsRemoved, Remark = model.Remark }); }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <param name="viruses"></param> /// <param name="raw"></param> /// <returns></returns> public static VirusHandleRecord ToModel(this VirusHandleRecordDataModel model, IQueryable <Virus> viruses, VirusHandleRecord raw = null) { if (raw == null) { raw = new VirusHandleRecord() { Create = DateTime.Now } } ; raw.Create = model.Create; raw.HandleStatus = model.HandleStatus; raw.Remark = model.Remark ?? raw.Remark; raw.Virus = viruses.FirstOrDefault(i => i.Key == model.Virus) ?? raw.Virus; raw.VirusKey = raw.Virus?.Key;// cache client info raw.IsRemoved = model.IsRemoved; return(raw); }