Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }