Ejemplo n.º 1
0
        //bind CertificateType
        private void SetCertificateTypeList(int?type, bool allowBlank = true)
        {
            ICertificateTypeService cs = new CertificateTypeService(Settings.Default.db);

            CertificateTypeSearchModel csm = new CertificateTypeSearchModel();

            List <CertificateType> certType = cs.Search(csm).ToList();

            List <SelectListItem> select = new List <SelectListItem>();

            if (allowBlank)
            {
                select.Add(new SelectListItem {
                    Text = "", Value = ""
                });
            }

            foreach (var certt in certType)
            {
                if (type.HasValue && type.ToString().Equals(certt.id))
                {
                    select.Add(new SelectListItem {
                        Text = certt.name, Value = certt.id.ToString(), Selected = true
                    });
                }
                else
                {
                    select.Add(new SelectListItem {
                        Text = certt.name, Value = certt.id.ToString(), Selected = false
                    });
                }
            }
            ViewData["certificateTypeList"] = select;
        }
Ejemplo n.º 2
0
        public IQueryable <CertificateType> Search(CertificateTypeSearchModel searchModel)
        {
            DataContext dc = new DataContext(this.DbString);
            ICertificateTypeRepository certfRep = new CertificateTypeRepository(dc);

            return(certfRep.Search(searchModel));
        }
Ejemplo n.º 3
0
        public IQueryable <CertificateType> Search(CertificateTypeSearchModel searchModel)
        {
            IQueryable <CertificateType> certf = this.context.CertificateType;

            if (!string.IsNullOrEmpty(searchModel.Name))
            {
                certf = certf.Where(c => c.name.Contains(searchModel.Name.Trim()));
            }
            return(certf);
        }
Ejemplo n.º 4
0
        public CertificateTypeInfoModel GetCertificateTypeInfo(CertificateTypeSearchModel searchModel)
        {
            CertificateTypeInfoModel info = new CertificateTypeInfoModel();
            DataContext dc = new DataContext(this.DbString);
            ICertificateTypeRepository   certfRep = new CertificateTypeRepository(dc);
            IQueryable <CertificateType> certfs   = certfRep.Search(searchModel);

            info.certfCount = dc.Context.GetTable <CertificateType>().Where(c => c.id.Equals(certfs.Count() > 0 ? certfs.First().id : -1)).Count();

            return(info);
        }
Ejemplo n.º 5
0
        public ActionResult Search([Bind(Include = "Name")] CertificateTypeSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            ICertificateTypeService ss = new CertificateTypeService(Settings.Default.db);

            IPagedList <CertificateType> certfs = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View("Index", certfs));
        }
Ejemplo n.º 6
0
        private void SetJobCertificateTypeList(List <JobCertificate> jobCertis, bool allowBlank = false)
        {
            ICertificateTypeService cs = new CertificateTypeService(Settings.Default.db);

            CertificateTypeSearchModel csm = new CertificateTypeSearchModel();

            List <CertificateType> certType = cs.Search(csm).ToList();

            List <SelectListItem> select = new List <SelectListItem>();

            if (allowBlank)
            {
                select.Add(new SelectListItem {
                    Text = "", Value = ""
                });
            }

            foreach (var certt in certType)
            {
                if (jobCertis != null)
                {
                    bool hasSelected = jobCertis.Where(k => k.certificateTypeId == certt.id).ToList().Count() > 0;

                    if (hasSelected)
                    {
                        select.Add(new SelectListItem {
                            Text = certt.name, Value = certt.id.ToString(), Selected = true
                        });
                    }
                    else
                    {
                        select.Add(new SelectListItem {
                            Text = certt.name, Value = certt.id.ToString(), Selected = false
                        });
                    }
                }
                else
                {
                    select.Add(new SelectListItem {
                        Text = certt.name, Value = certt.id.ToString(), Selected = false
                    });
                }
            }

            ViewData["jobCertificateTypeList"] = select;
        }
Ejemplo n.º 7
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            CertificateTypeSearchModel q = new CertificateTypeSearchModel();

            ICertificateTypeService ss = new CertificateTypeService(Settings.Default.db);

            IPagedList <CertificateType> certfs = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            CertificateTypeInfoModel info = ss.GetCertificateTypeInfo(q);

            ViewBag.Info = info;

            return(View(certfs));
        }