public StatusCount GetStatusCount(string userName, string GreenType) { var statusCount = new StatusCount(); try { var lstCustomer = _customer.Find(c => c.UserName == userName && c.GreenType == GreenType).ToList(); if (lstCustomer != null && lstCustomer.Count > 0) { var statusdraft = lstCustomer.Where(l => string.Equals(l.Status, CustomerStatus.DRAFT, StringComparison.CurrentCultureIgnoreCase)).ToList().Count; var statusreturn = lstCustomer.Where(l => string.Equals(l.Status, CustomerStatus.RETURN, StringComparison.CurrentCultureIgnoreCase)).ToList().Count; var statussubmit = lstCustomer.Where(l => string.Equals(l.Status, CustomerStatus.SUBMIT, StringComparison.CurrentCultureIgnoreCase)).ToList().Count; var statusreject = lstCustomer.Where(l => string.Equals(l.Status, CustomerStatus.REJECT, StringComparison.CurrentCultureIgnoreCase)).ToList().Count; var statusapprove = lstCustomer.Where(l => string.Equals(l.Status, CustomerStatus.APPROVE, StringComparison.CurrentCultureIgnoreCase)).ToList().Count; var all = lstCustomer.Count; statusCount.Draft = statusdraft; statusCount.Return = statusreturn; statusCount.Submit = statussubmit; statusCount.Approve = statusapprove; statusCount.All = all; } } catch (Exception ex) { _logger.LogError(ex, ex.Message); } return(statusCount); }
private static void AreEqual(StatusCount exp, StatusCount act) { if (exp != null) { AreEqual(exp.Status, act.Status); Assert.Equal(exp.Count, act.Count); } }
public static void convertCsvToDictionary(List <dynamic> LocationList, string type) { foreach (var lcsv in LocationList) { var dict = (IDictionary <string, object>)lcsv; string Country = lcsv.countryregion.ToLower(); string Province = lcsv.provincestate.ToLower(); if (!String.IsNullOrEmpty(Country)) { CountryRegions.Add(Country.ToLower()); } if (!String.IsNullOrEmpty(Province)) { ProvinceStates.Add(Province.ToLower()); LocationKey lk = new LocationKey(Country, Province); if (!CountryProvinces.ContainsKey(Country)) { CountryProvinces.Add(Country, new Country()); } //CountryProvinces.Add(lk, new Location(Country, Province, new Coordinates(lcsv.Lat, lcsv.Long))); else { if (!CountryProvinces[Country].Provinces.Contains(Province)) { CountryProvinces[Country].Provinces.Add(Province); } } } DateTime firstDate = DateTime.Parse("1/1/2020"); DateTime endDate = DateTime.Now; int daysToAttempt = (endDate - firstDate).Days + 10; for (int i = 0; i < daysToAttempt; i++) { StatusCount statusCount = new StatusCount(); DateTime dateToAttempt = firstDate.AddDays(i); string targetDay = dateToAttempt.ToString("Mdyy"); if (dict.TryGetValue(targetDay, out var count) && !String.IsNullOrEmpty(count.ToString())) { int intcount = int.Parse(count.ToString()); if (type == "Confirmed") { statusCount.Confirmed = intcount; } else if (type == "Deaths") { statusCount.Deaths = intcount; } else if (type == "Recovered") { statusCount.Recovered = intcount; } Occurences occurences = new Occurences(); occurences.DateOccurrences.Add(dateToAttempt, statusCount); LocationKey location = new LocationKey(Country.ToLower(), Province.ToLower()); if (!LocationOccurrences.ContainsKey(location)) { LocationOccurrences.Add(location, occurences); } if (!LocationOccurrences[location].DateOccurrences.ContainsKey(dateToAttempt)) { LocationOccurrences[location].DateOccurrences[dateToAttempt] = new StatusCount(); } if (type == "Confirmed") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Confirmed = statusCount.Confirmed; } else if (type == "Deaths") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Deaths = statusCount.Deaths; } else if (type == "Recovered") { LocationOccurrences[location].DateOccurrences[dateToAttempt].Recovered = statusCount.Recovered; } } } } }