public int CountByChannel(int branchId, int sourceTypeId, int levelId, int channelId, string from, string to) { try { var dtFrom = string.IsNullOrEmpty(from) ? DateTime.Now.Date : DateTime.ParseExact(from, "dd/MM/yyyy", CultureInfo.InstalledUICulture); var dtTo = string.IsNullOrEmpty(from) ? DateTime.Now.AddDays(1).Date : DateTime.ParseExact(to, "dd/MM/yyyy", CultureInfo.InstalledUICulture); return(ContactRepository.CountByChannel(branchId, sourceTypeId, levelId, channelId, dtFrom, dtTo)); } catch { return(0); } }