private IEnumerable <TacNghiepResult> Find(ValueSearchStatisticViewModel model)
        {
            var all = TacNghiepRepository.GetAll();

            if (model.CoQuanId.HasValue)
            {
                all = all.Where(x => x.CoQuanInfos.Any(y => y.Id == model.CoQuanId.Value));
            }

            if (model.LinhVucTacNghiepId.HasValue)
            {
                all = all.Where(x => x.LinhVucTacNghiepId == model.LinhVucTacNghiepId.Value);
            }

            if (model.MucDoHoanThanhId.HasValue)
            {
                all = all.Where(x => x.MucDoHoanThanhId == model.MucDoHoanThanhId.Value);
            }

            if (model.From.HasValue)
            {
                all = all.Where(x => x.NgayTao >= model.From.Value);
            }

            if (model.To.HasValue)
            {
                all = all.Where(x => x.NgayTao <= model.To.Value);
            }

            return(all);
        }
        public ActionResult Detail(int id)
        {
            //Get all co quan lien qua by tacNghiepId
            var cqlq   = TacNghiepTinhHinhThucHienRepository.GetAllByTacNghiepId(id);
            var lvtn   = LinhVucTacNghiepRepository.GetAll().Select(x => x.ToDataInfo());
            var result = TacNghiepRepository.Single(id);
            var ncq    = new List <InitCoQuanCoLienQuan>();

            NhomCoQuanRepository.GetAllWithChildren().ToList().ForEach(x =>
            {
                ncq.Add(new InitCoQuanCoLienQuan
                {
                    NhomCoQuan  = x.ToDataInfo(),
                    CoQuanInfos = x.CoQuanResult.Select(s => s.ToDataInfo()).ToList().Update((r) =>
                    {
                        r.ToList().ForEach(f =>
                        {
                            f.IsSelected = cqlq.Where(w => w.CoQuanId == f.Id).Any();
                        });
                    }).ToList(),
                });
            });

            //get files in folder upload
            var urlFiles = EnsureFolderTacNghiep(id);

            var detail = new DetailTacNghiepViewModel
            {
                Id                       = id,
                NgayHetHan               = result.NgayHetHan,
                NgayHoanThanh            = result.NgayHoanThanh,
                NgayTao                  = result.NgayTao,
                NoiDung                  = result.NoiDung,
                NoiDungYKienTraoDoi      = result.NoiDungTraoDoi,
                LinhVucTacNghiepId       = result.LinhVucTacNghiepInfo.Id,
                CoQuanInfos              = cqlq,
                LinhVucTacNghiepInfo     = lvtn,
                NhomCoQuanCoLienQuanInfo = ncq,
                JsonFiles                = GetPathFiles(urlFiles),
                IsRoleAdmin              = User.IsInRole(RoleConstant.SUPPER_ADMIN) || User.IsInRole(RoleConstant.ADMIN),
            };

            return(View(detail));
        }
        public JsonResult EditRecord(DetailTacNghiepViewModel model)
        {
            return(ExecuteWithErrorHandling(() =>
            {
                var result = TacNghiepRepository.Single(model.Id);

                result.NgayTao = model.NgayTao;
                result.NgayHoanThanh = model.NgayHoanThanh;
                result.NgayHetHan = model.NgayHetHan;
                result.NoiDung = model.NoiDung;
                result.NoiDungTraoDoi = model.NoiDungYKienTraoDoi;
                result.LastUpdatedBy = UserName;

                return ExecuteResult(() =>
                {
                    return TacNghiepRepository.Update(result);
                });
            }));
        }
        public JsonResult AddRecord(AddTacNghiepViewModel model)
        {
            return(ExecuteWithErrorHandling(() =>
            {
                var entity = model.ToTacNghiepResult().Update(x =>
                {
                    x.CreatedBy = UserName;
                    x.MucDoHoanThanhId = (int)EnumMucDoHoanThanh.CHUATHUHIEN;
                });
                return ExecuteResult(() =>
                {
                    var saveResult = TacNghiepRepository.AddTacNghiepWithTinhHinhThucHien(entity);

                    if (entity.Id > 0)
                    {
                        MoveFilesTacNghiep(model.Guid, entity.Id);
                    }

                    return saveResult;
                });
            }));
        }
        private IPagedList <TacNghiepResult> Find(ValueSearchViewModel model)
        {
            var seachAll = TacNghiepRepository.Find(model.ToValueSearch());

            return(seachAll.ToPagedList(model.Page, TechOfficeConfig.PAGESIZE));
        }