public async Task <ActionResult> ViewDateRangeLeads(DateTime?from, DateTime?to) { if (from == null || to == null || from > to) { return(Json("Invalid", JsonRequestBehavior.AllowGet)); } to = to.Value.AddDays(1); tbl_emp_info loggedInUserInfo = Utilities.GetLoggedInUserInfo(User.Identity.Name); int? loggedInUser = loggedInUserInfo.Emp_ID; if (loggedInUser == null) { return(new HttpUnauthorizedResult()); } List <tbl_crm_leads> leadsList = new List <tbl_crm_leads>(); if (User.IsInRole(Permissions.CRM.VIEW_ALL_LEADS)) { leadsList = await leadsManager.GetDateRangeAllLeadsAsync(from, to).ConfigureAwait(false); } else if (User.IsInRole(Permissions.CRM.VIEW_OWN_LEADS)) { leadsList = await leadsManager.GetDateRangeOwnLeadsAsync(from, to, loggedInUser).ConfigureAwait(false); } return(PartialView(leadsList)); }