public async Task <ApiResult> GetDetailByID(int id) { ApiResult ret = new ApiResult(); try { Equipment e = await _eqpRepo.GetDetailByID(id); List <AllArea> laa = await _eqpRepo.GetAllArea(); e.LocationName = laa.Where(a => a.Tablename == e.LocationBy && a.ID == e.Location) .FirstOrDefault().AreaName; var list = await _uploadFileRepo.ListByEntity(new int[] { id }, MyDictionary.SystemResource.Eqp); if (list != null) { e.FileIDs = JsonConvert.SerializeObject(UploadFileHelper.ListShow(list)); } ret.data = e; return(ret); } catch (Exception ex) { ret.code = Code.Failure; ret.msg = ex.Message; return(ret); } }
public async Task <ApiResult> CascaderByIDs(string ids) { ApiResult ret = new ApiResult(); try { List <UploadFile> ufs = await _uploadFileRepo.ListByIDs(ids); ret.data = UploadFileHelper.CascaderShow(ufs); return(ret); } catch (Exception ex) { ret.code = Code.Failure; ret.msg = ex.Message; return(ret); } }
public async Task <ApiResult> ListByEntity(int[] entitys, SystemResource sr, UploadShowType ust) { ApiResult ret = new ApiResult(); try { List <object> objs = new List <object>(); List <UploadFile> ufs = await _uploadFileRepo.ListByEntity(entitys, sr); if (ufs != null && ufs.Count() > 0) { IEnumerable <IGrouping <int, UploadFile> > groupAction = ufs.GroupBy(a => a.Entity); foreach (IGrouping <int, UploadFile> group in groupAction) { if (ust == UploadShowType.Cascader) { objs.Add(new { Entity = group.Key, UploadFiles = JsonConvert.SerializeObject(UploadFileHelper.CascaderShow(group.ToList())) }); } else if (ust == UploadShowType.List) { objs.Add(new { Entity = group.Key, UploadFiles = JsonConvert.SerializeObject(UploadFileHelper.ListShow(group.ToList())) }); } } } ret.data = objs; return(ret); } catch (Exception ex) { ret.code = Code.Failure; ret.msg = ex.Message; return(ret); } }
public async Task <ApiResult> ListByEqp(int id) { ApiResult ret = new ApiResult(); try { List <UploadFile> ufs = await _uploadFileRepo.ListByEntity(new int[] { id }, SystemResource.Eqp); if (ufs != null) { ret.data = UploadFileHelper.TimeLineShow(ufs); } return(ret); } catch (Exception ex) { ret.code = Code.Failure; ret.msg = ex.Message; return(ret); } }
public async Task <ApiResult> GetByID(int id) { ApiResult ret = new ApiResult(); try { Equipment e = await _eqpRepo.GetByID(id); var list = await _uploadFileRepo.ListByEntity(new int[] { id }, MyDictionary.SystemResource.Eqp); if (list != null) { e.FileIDs = JsonConvert.SerializeObject(UploadFileHelper.ListShow(list)); } ret.data = e; return(ret); } catch (Exception ex) { ret.code = Code.Failure; ret.msg = ex.Message; return(ret); } }