Ejemplo n.º 1
0
        public JsonResult getEcozone(string Dev)
        {
            try
            {
                var code    = Dev.Split('~');
                var DevName = code[0];
                var EcoName = code[1];
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                ApplicationDbContext context    = new ApplicationDbContext();
                //DeveloperDetailsViewModel samp = new DeveloperDetailsViewModel();
                ReportTable       DeveloperList = new ReportTable();
                List <devdetails> samp          = new List <devdetails>();
                DeveloperDetails1 devd          = new DeveloperDetails1();
                var    userid      = User.Identity.GetUserId();
                string zoneGroup   = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
                var    ZoneGroupId = db.ZoneGroup.FirstOrDefault(x => x.ZoneGroupCode == zoneGroup).ZoneGroupId.ToString();
                var    ZoneCode    = db.Zone.Where(x => x.ZoneGroup == ZoneGroupId).Select(x => x.ZoneCode).ToString();

                if (Dev.Length >= 4)
                {
                    var dev = db.Database.SqlQuery <DeveloperDetails>("SELECT DISTINCT Dev_Comp_Code, Zone_Code from AdminFees left join Zones on AdminFees.Zone_Code = Zones.ZoneCode where AdminFees.Developer = '" + DevName + "'  AND AdminFees.Ecozone = '" + EcoName + "'").ToList().Take(1);
                    return(Json(dev));
                }
            }
            catch { }
            return(Json(null));
        }
Ejemplo n.º 2
0
        //JSON RESULT FOR DEVELOPER
        public JsonResult GetDevelopers(string Dev)
        {
            //var Devlist = db.AdminFee.Select(m => m.Developer).Distinct().ToList();
            //try
            //{
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            ApplicationDbContext context    = new ApplicationDbContext();
            //DeveloperDetailsViewModel samp = new DeveloperDetailsViewModel();
            ReportTable       DeveloperList = new ReportTable();
            List <devdetails> samp          = new List <devdetails>();
            DeveloperDetails1 devd          = new DeveloperDetails1();
            var    userid      = User.Identity.GetUserId();
            string zoneGroup   = context.Users.SingleOrDefault(m => m.Id == userid).ZoneGroup;
            var    ZoneGroupId = db.ZoneGroup.FirstOrDefault(x => x.ZoneGroupCode == zoneGroup).ZoneGroupId.ToString();
            var    ZoneCode    = db.Zone.Where(x => x.ZoneGroup == ZoneGroupId).Select(x => x.ZoneCode).ToString();

            if (Dev.Length >= 4)
            {
                var dev = db.Database.SqlQuery <DeveloperDetails>("SELECT DISTINCT Dev_Comp_Code, Developer, Zone_Code, Ecozone from AdminFees left join Zones on AdminFees.Zone_Code = Zones.ZoneCode where AdminFees.Developer like '%" + Dev + "%'").ToList();
                //foreach (var items in dev)
                //{
                //    devdetails temp = new devdetails();
                //    //samp.DeveloperId1.Add(items.DeveloperId);
                //    temp.Dev_Comp_Code=items.Dev_Comp_Code;
                //    temp.Developer=items.Developer;
                //    temp.Ecozone=items.Ecozone;
                //    temp.Zone_Code=items.Zone_Code;
                //    samp.Add(temp);
                //}
                devd.dev = samp;
                //db.Database.SqlQuery<DeveloperDetails>("SELECT DISTINCT Dev_Comp_Code, Developer, Zone_Code, Ecozone from AdminFees left join Zones on AdminFees.Zone_Code = Zones.ZoneCode where AdminFees.Developer like '%" + Dev + "%'").ToList();
                //var devs = db.AdminFee.Select(o => o.Zone_Code == ZoneCode && o.Developer.Contains(Dev)).ToList();

                //var devs = from af in db.AdminFee
                //           join z in db.Zone on af.Zone_Code equals z.ZoneCode
                //           where z.ZoneGroup == ZoneGroupId && af.Developer.Contains(Dev)
                //           select af;

                //devs.ToList();

                //var devs1 = devs.Contains(Dev).ToString().Take(15);

                //foreach (var item in devs1)
                //{
                //        //var devs = db.Database.SqlQuery<AdminFee>("select AdminFees.* from AdminFees left join Zones on AdminFees.Zone_Code = Zones.ZoneCode where Zones.ZoneGroup = '" + ZoneGroupId + "'").ToList();
                //        DeveloperList.DeveloperName.Add(item.ToString());
                //        //DeveloperList.DeveloperName.Add(db.AdminFee.Where(x => x.Zone_Code == item.ZoneCode).FirstOrDefault().Developer);
                //        //catch (Exception ex) { }

                //}

                ////var a = DeveloperList;
                //try
                //{
                //    //var Devlist1 = DeveloperList.DeveloperName.Contains(Dev).ToString().Take(15);
                //    return Json(devs);
                //}
                //catch { }

                return(Json(dev));
            }
            //}
            //catch { }
            return(Json(null));
        }