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);
        }
Example #2
0
        public JsonResult GetCoQuanByNhomCoQuan(int nhomCoQuanId)
        {
            return(ExecuteWithErrorHandling(() =>
            {
                var result = CoQuanRepository.GetAllByNhomCoQuanId(nhomCoQuanId);
                var jsonResult = result.Aggregate("<option selected='selected' value>Tất cả</option>",
                                                  (current, item) => current + $"<option value={item.Id}>{item.Ten}</option>");

                return new JsonResult
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = jsonResult
                };
            }));
        }