Ejemplo n.º 1
0
        public JsonResult AllIndicationNames(string prefix)
        {
            DrugInformationContext db = new DrugInformationContext();

            var indicationNames = (from names in db.Indications
                                   where names.IndicationName.Contains(prefix)
                                   select new
            {
                id = names.Id,
                indicationName = names.IndicationName
            }).Take(30).ToList();

            return(Json(indicationNames));
        }
Ejemplo n.º 2
0
        public JsonResult AllCompanyNames(string prefix)
        {
            DrugInformationContext db = new DrugInformationContext();

            var pharmaNames = (from names in db.PharmaCompanies
                               where names.PharmaName.Contains(prefix)
                               select new
            {
                id = names.Id,
                pharmaNames = names.PharmaName
            }).Take(30).ToList();

            return(Json(pharmaNames));
        }
Ejemplo n.º 3
0
        public JsonResult AllGenericNames(string prefix)
        {
            DrugInformationContext db = new DrugInformationContext();

            var genericNames = (from names in db.DrugGenerics
                                where names.GenericName.StartsWith(prefix)
                                select new
            {
                id = names.Id,
                genericName = names.GenericName
            }).Take(15).ToList();

            return(Json(genericNames));
        }
Ejemplo n.º 4
0
        public JsonResult AllBrandNames(string prefix)
        {
            DrugInformationContext db = new DrugInformationContext();

            var drugsName = (from names in db.DrugBrandInfos
                             where names.BrandName.StartsWith(prefix)
                             select new
            {
                brandName = names.BrandName,
                drugForm = names.DrugForm,
                drugStrength = names.DrugStrength
            }).Take(10).ToList();

            return(Json(drugsName));
        }
        public ActionResult LoadData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            //Get parameters

            // get Start (paging start index) and length (page size for paging)
            var draw   = Request.Form.GetValues("draw").FirstOrDefault();
            var start  = Request.Form.GetValues("start").FirstOrDefault();
            var length = Request.Form.GetValues("length").FirstOrDefault();
            //Get Sort columns value
            var sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();

            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int totalRecords = 0;

            using (DrugInformationContext dc = new DrugInformationContext())
            {
                dc.Configuration.LazyLoadingEnabled = false;

                var v = (from a in dc.DrugBrandInfos.Where(c => c.BrandName != null) select a);

                // Apply filters
                if (requestModel.Search.Value != String.Empty)
                {
                    var value = requestModel.Search.Value.Trim();
                    v = v.Where(p => p.BrandName.Contains(value) || p.DrugForm.Contains(value) || p.PackSize.Contains(value));
                }


                //Sorting
                if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir)))
                {
                    v = v.OrderBy(sortColumn + " " + sortColumnDir);
                }



                totalRecords = v.Count();
                var data = v.Skip(skip).Take(pageSize).ToList();
                return(Json(new { draw = draw, recordsFiltered = totalRecords, recordsTotal = totalRecords, data = data }, JsonRequestBehavior.AllowGet));
            }
        }