private InitTacNghiepViewModel CreateTacNghiepModel(int?nhomCoQuanId) { var model = new InitTacNghiepViewModel { LinhVucTacNghiepInfo = LinhVucTacNghiepRepository.GetAll().Select(x => x.ToDataInfo()), MucDoHoanThanhInfo = MucDoHoanThanhRepository.GetAll(), NhomCoQuanInfos = NhomCoQuanRepository.GetAll().Select(x => x.ToDataInfo()), }; //Check user has role allow select nhom co quan and co quan when statistic if (User.IsInRole(RoleConstant.ALLOW_SELECT)) { model.CoQuanInfos = nhomCoQuanId.HasValue ? CoQuanRepository.GetAllByNhomCoQuanId(nhomCoQuanId.Value).Select(x => x.ToDataInfo()).ToList() : new List <CoQuanInfo>(); } else { var user = AuthInfo(); model.NhomCoQuanId = user.CoQuanInfo.NhomCoQuanId; model.CoQuanId = user.CoQuanId; model.CoQuanInfos = new List <CoQuanInfo>() { user.CoQuanInfo }; } //end check return(model); }
public ActionResult Add() { List <InitCoQuanCoLienQuan> coquanInfos = new List <InitCoQuanCoLienQuan>(); NhomCoQuanRepository.GetAllWithChildren().ToList().ForEach(x => { coquanInfos.Add(new InitCoQuanCoLienQuan { NhomCoQuan = x.ToDataInfo(), CoQuanInfos = x.CoQuanResult.Select(s => s.ToDataInfo()).ToList() }); }); var linhVucs = LinhVucTacNghiepRepository.GetAll().Select(x => x.ToDataInfo()); var model = new AddTacNghiepViewModel { Guid = Guid.NewGuid().ToString(), NgayTao = DateTime.Now, NgayHetHan = DateTime.Now, NgayHoanThanh = DateTime.Now, CoQuanInfos = coquanInfos, LinhVucInfos = linhVucs, }; return(View(model)); }
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)); }