예제 #1
0
        public IActionResult Producers(int[] c, int[] i)
        {
            var selc = c.ToList();
            var seli = i.ToList();

            ViewData["comunas"] = from Comuna u in _context.Comuna
                                  .Where(a => a.Id != 0 &&
                                         a.Centres.Any(b => b.Type == CentreTypes.Cultivo))
                                  .Include(a => a.Centres)
                                  .Include(a => a.Provincia)
                                  .ThenInclude(a => a.Region)
                                  select new BSSVM {
                Selected = selc.Contains(u.Id),
                Subtext  =
                    $"{StringManipulations.ToRomanNumeral(u.Provincia.Region.Id)} {u.Provincia.Region.Name}, {u.Provincia.Name}",
                Value  = u.Id,
                Text   = u.Name,
                Tokens = string.Join(" ", u.Centres.Select(k => k.Address))
            };

            TextInfo textInfo = new CultureInfo("es-CL", false).TextInfo;

            ViewData["company"] = from Company u in _context.Company
                                  .Where(a => a.Acronym != null)
                                  select new BSSVM
            {
                Tokens   = u.BsnssName + string.Join(" ", u.Centres.Select(k => k.Address)),
                Selected = seli.Contains(u.Id),
                Subtext  =
                    $"({u.Acronym}) {u.Id}-{StringManipulations.GetDigit(u.Id)}",
                Value  = u.Id,
                Text   = textInfo.ToTitleCase(textInfo.ToLower(u.BsnssName.Substring(0, Math.Min(u.BsnssName.Length, 50)))),
                Hellip = u.BsnssName.Length > 50
            };

            ViewData["c"] = string.Join(",", c);
            ViewData["i"] = string.Join(",", i);

            var centres = _context.Centre
                          .Where(
                a => a.Type == (CentreTypes)1 && a.CompanyId != 55555555)
                          .Include(a => a.Coordinates)
                          .Where(
                a => a.Coordinates.Any() &&
                c.Any() && a.ComunaId.HasValue ? selc.Contains(a.ComunaId.Value) : true &&
                i.Any() ? seli.Contains(a.CompanyId) : true
                )
                          .Include(a => a.Company)
                          .Include(a => a.Samplings)
                          .Include(a => a.Comuna)
                          .ThenInclude(a => a.Provincia)
                          .ThenInclude(a => a.Region);

            return(View(centres));
        }
예제 #2
0
        public string Format(String format, Object obj, IFormatProvider provider)
        {
            // Display information about method call.
            if (!this.Equals(provider))
            {
                return(null);
            }

            // Set default format specifier
            if (string.IsNullOrEmpty(format))
            {
                format = "N";
            }

            string numericString = obj.ToString();

            if (obj is int && format.ToUpper().Equals("U"))
            {
                return(String.Format("{0,9:N0}-{1}", obj, StringManipulations.GetDigit((int)obj)));
            }

            if (obj is string && format.ToUpper().Equals("I"))
            {
                return(Regex.Replace(obj.ToString(), "-.*", "").Replace(".", ""));
            }

            // If this is a byte and the "R" format string, format it with Roman numerals.
            if (obj is int && format.ToUpper().Equals("R"))
            {
                return(StringManipulations.ToRomanNumeral((int)obj));
            }

            // Use default for all other formatting.
            if (obj is IFormattable)
            {
                return(((IFormattable)obj).ToString(format, CultureInfo.CreateSpecificCulture("es-CL")));
            }
            else
            {
                return(obj.ToString());
            }
        }
예제 #3
0
        public string Format(string format, object obj, IFormatProvider provider)
        {
            // Display information about method call.
            if (!Equals(provider))
            {
                return(null);
            }

            // Set default format specifier
            if (string.IsNullOrEmpty(format))
            {
                format = "N";
            }

            //string numericString = obj.ToString();

            if (obj is int && format.Equals("U", StringComparison.InvariantCultureIgnoreCase))
            {
                return(string.Format(CultureInfo.InvariantCulture, "{0,9:N0}-{1}", obj, StringManipulations.GetDigit((int)obj)));
            }

            // If this is a byte and the "R" format string, format it with Roman numerals.
            if (obj is int && format.Equals("R", StringComparison.InvariantCultureIgnoreCase))
            {
                return(StringManipulations.ToRomanNumeral((int)obj));
            }

            // Use default for all other formatting.
            if (obj is IFormattable)
            {
                return(((IFormattable)obj).ToString(format, CultureInfo.CurrentCulture));
            }
            else
            {
                return(obj?.ToString());
            }
        }
예제 #4
0
        public IActionResult Research(int[] c, int[] i)
        {
            var selc = c.ToList();
            var seli = i.ToList();

            ViewData["comunas"] = from Comuna u in _context.Comuna
                                  .Where(a => a.Id != 0 &&
                                         a.Centres.Any(b => b.Type == CentreTypes.Investigacion))
                                  .Include(a => a.Centres)
                                  .Include(a => a.Provincia)
                                  .ThenInclude(a => a.Region)
                                  select new BSSVM {
                Selected = selc.Contains(u.Id),
                Subtext  =
                    $"{StringManipulations.ToRomanNumeral(u.Provincia.Region.Id)} {u.Provincia.Region.Name}, {u.Provincia.Name}",
                Value = u.Id,
                Text  = u.Name
            };

            TextInfo textInfo = new CultureInfo("es-CL", false).TextInfo;

            ViewData["company"] = from Company u in _context.Company
                                  .Where(a => a.Acronym != null)
                                  select new BSSVM {
                Icon     = $"bib-{u.Acronym}-mono",
                Tokens   = u.BsnssName,
                Selected = seli.Contains(u.Id),
                Subtext  =
                    $"({u.Acronym}) {u.Id}-{StringManipulations.GetDigit(u.Id)}",
                Value  = u.Id,
                Text   = textInfo.ToTitleCase(textInfo.ToLower(u.BsnssName.Substring(0, Math.Min(u.BsnssName.Length, 50)))),
                Hellip = u.BsnssName.Length > 50
            };

            ViewData["c"] = string.Join(",", c);
            ViewData["i"] = string.Join(",", i);

            var centres = _context.Centre
                          .Where(
                a => a.Type == (CentreTypes)5 && a.CompanyId != 55555555)
                          .Include(a => a.Coordinates)
                          .Where(
                a => a.Coordinates.Any() &&
                c.Any() && a.ComunaId.HasValue ? selc.Contains(a.ComunaId.Value) : true &&
                i.Any() ? seli.Contains(a.CompanyId) : true
                )
                          .Include(a => a.Company)
                          .Include(a => a.Comuna)
                          .ThenInclude(a => a.Provincia)
                          .ThenInclude(a => a.Region);

            var polygons = new List <object>();

            foreach (var g in centres)
            {
                polygons.Add(g.Coordinates.OrderBy(o => o.Vertex).Select(m =>
                                                                         new {
                    lat = m.Latitude,
                    lng = m.Longitude
                }));
            }



            return(View(centres));
        }