public Dictionary <string, int> GetCountPerDateBy2(string productType, DateTime? @from = null, DateTime?to = null) { from = DateTime.Now.AddDays(-2); if (to == null) { to = DateTime.Now; } var response = _receiptRepository.GetCountPerDateBy2(productType, from, to); DateTime aux = DateTime.Now; if (from == null) { string strfrom = response.Min(r => r.Key) ?? DateTime.Now.ToString("yyyy-MM-dd"); aux = new DateTime(Convert.ToInt32(strfrom.Split('-')[0]), Convert.ToInt32(strfrom.Split('-')[1]), Convert.ToInt32(strfrom.Split('-')[2])); } else { aux = new DateTime(from.Value.Year, from.Value.Month, from.Value.Day); } while (aux < to) { if (response.ContainsKey(aux.ToString("yyyy-MM-dd"))) { } else { response.Add(aux.ToString("yyyy-MM-dd"), 0); } aux = aux.AddDays(1); } return(response); }