Exemplo n.º 1
0
        public BaseDataContainer GetWorkListByServiceCatJob(int serviceCatJobId, bool loadParents)
        {
            BaseDataTDataAccess           da      = new BaseDataTDataAccess();
            ServiceCategoryJobTDataAccess scJobDa = new ServiceCategoryJobTDataAccess();
            var scjob        = scJobDa.GetSingle(it => it.ServiceCatJobId == serviceCatJobId);
            var serviceCatId = scjob.Servicecategoryid.Value;
            ServiceCategoryTDataAccess scDa = new ServiceCategoryTDataAccess();
            var serviceCat            = scDa.GetSingle(it => it.ServiceCatId == serviceCatId);
            List <SdWorkDto> workList = new List <SdWorkDto>();

            workList = da.GetWorks(serviceCatId);
            if (loadParents)
            {
                if (serviceCat.Parentid.HasValue != null)
                {
                    SdServiceCategoryDto temp = scDa.GetSingle(it => it.ServiceCatId == serviceCat.Parentid.Value);
                    while (temp != null)
                    {
                        var tworkList = da.GetWorks(temp.ServiceCatId);
                        if (tworkList != null)
                        {
                            workList.AddRange(tworkList);
                        }
                        if (temp.Parentid.HasValue)
                        {
                            temp = scDa.GetSingle(it => it.ServiceCatId == temp.Parentid.Value);
                        }
                        else
                        {
                            temp = null;
                        }
                    }
                }
            }


            BaseDataContainer container = new BaseDataContainer()
            {
                WorkList = workList
            };

            return(container);
        }
        public UserRequestDtoContainer GetRequestWorkList(int requestId)
        {
            UserRequestDtoContainer container = new UserRequestDtoContainer();
            PersonelTDataAccess     pda       = new PersonelTDataAccess();
            RequestWorkTDataAccess  requestDa = new RequestWorkTDataAccess();
            BaseDataTDataAccess     baseDa    = new BaseDataTDataAccess();
            var dtoList = requestDa.GetAll(it => it.RequestId == requestId);
            var wList   = baseDa.GetWorks();

            foreach (var item in dtoList)
            {
                var pers = pda.GetPersonId(item.UserId ?? 0);
                item.Work = wList.Where(it => it.WorkId == item.SdWorkId).FirstOrDefault();
                item.User = pers;
            }
            if (dtoList != null)
            {
                container.SdRequestWorkDtolist.AddRange(dtoList);
            }
            return(container);
        }