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)); }
public async Task <ActionResult> Edit(LeadsEditViewModel updateLeads) { if (ModelState.IsValid) { tbl_crm_leads updatedLead = Mapper.Map <LeadsEditViewModel, tbl_crm_leads>(updateLeads); tbl_emp_info loggedInUserInfo = Utilities.GetLoggedInUserInfo(User.Identity.Name); int? loggedInUser = loggedInUserInfo.Emp_ID; updatedLead.Generated_By = loggedInUser; updatedLead.UpdatedAt = DateTime.Now; ResponseMessage responseMessage = await leadsManager.EditAsync(updatedLead).ConfigureAwait(false); if (responseMessage.Type == Constant.RESPONSE_MESSAGE_TYPE_SUCCESS) { return(Json(GeneralMessages.SAVE_SUCCESSFUL, JsonRequestBehavior.AllowGet)); } else { return(Json(GeneralMessages.SAVE_FAILED, JsonRequestBehavior.AllowGet)); } } else { return(Json(GeneralMessages.SAVE_FAILED, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> CrmDashboard() { tbl_emp_info loggedInUserInfo = Utilities.GetLoggedInUserInfo(User.Identity.Name); int? loggedInUser = loggedInUserInfo.Emp_ID; int myTotalLeads = 0; int myTotalLeadsToday = 0; int TotalLeads = 0; int TotalLeadsToday = 0; int numberOfHighPrioritytask = 0; int totalTask = 0; List <tbl_crm_task> todaysCallList = new List <tbl_crm_task>(); List <tbl_crm_task> todaysAppointmentList = new List <tbl_crm_task>(); List <tbl_crm_task> todaysOtherTaskList = new List <tbl_crm_task>(); if (loggedInUser == null) { return(new HttpUnauthorizedResult()); } else { if (User.IsInRole(Permissions.CRM.VIEW_OWN_CRM_DASHBOARD)) { myTotalLeads = await leadsManager.GetMyTotalLeadsAsync(loggedInUser).ConfigureAwait(false); myTotalLeadsToday = await leadsManager.GetMyTotalLeadsTodayAsync(loggedInUser).ConfigureAwait(false); } else if (User.IsInRole(Permissions.CRM.VIEW_CRM_DASHBOARD)) { TotalLeads = await leadsManager.GetTotalLeadsAsync().ConfigureAwait(false); TotalLeadsToday = await leadsManager.GetTotalLeadsTodayAsync().ConfigureAwait(false); } if (User.IsInRole(Permissions.CRM.VIEW_OWN_TASKS)) { numberOfHighPrioritytask = await taskManager.GetNumberOfInCompleteHighPriorityTaskAsync(loggedInUser).ConfigureAwait(false); totalTask = await taskManager.GetTotalIncompleteTaskAsync(loggedInUser).ConfigureAwait(false); todaysCallList = await taskManager.GetTodaysCallListAsync(loggedInUser).ConfigureAwait(false); todaysAppointmentList = await taskManager.GetTodaysAppointmentListAsync(loggedInUser).ConfigureAwait(false); todaysOtherTaskList = await taskManager.GetTodaysOtherTaskListAsync(loggedInUser).ConfigureAwait(false); } ViewBag.MyTotalLeads = myTotalLeads; ViewBag.MyTotalLeadsToday = myTotalLeadsToday; ViewBag.TotalLeads = TotalLeads; ViewBag.TotalLeadsToday = TotalLeadsToday; ViewBag.HighPriorityTask = numberOfHighPrioritytask; ViewBag.TotalTask = totalTask; ViewBag.TodaysCallList = todaysCallList; ViewBag.TodaysAppointmentList = todaysAppointmentList; ViewBag.TodaysOtherTaskList = todaysOtherTaskList; return(View()); } }
public async Task <ActionResult> Index() { tbl_emp_info loggedInUserInfo = Utilities.GetLoggedInUserInfo(User.Identity.Name); int? loggedInUser = loggedInUserInfo.Emp_ID; string permission = ""; if (loggedInUser == null) { return(new HttpUnauthorizedResult()); } List <tbl_crm_leads> allLeadList = new List <tbl_crm_leads>(); if ((!User.IsInRole(Permissions.CRM.VIEW_ALL_LEADS)) && (User.IsInRole(Permissions.CRM.VIEW_OWN_LEADS))) { allLeadList = await db.tbl_crm_leads.Where(i => i.Generated_By == loggedInUser && i.ActionType != Constant.DELETE).ToListAsync().ConfigureAwait(false); permission = Permissions.CRM.VIEW_OWN_LEADS; } else if (User.IsInRole(Permissions.CRM.VIEW_ALL_LEADS)) { allLeadList = await db.tbl_crm_leads.Where(i => i.ActionType != Constant.DELETE).ToListAsync().ConfigureAwait(false); permission = Permissions.CRM.VIEW_ALL_LEADS; } ViewBag.NumberOfContactedLeads = await leadsManager.GetNumberOfContactedLeadsAsync(loggedInUser, permission).ConfigureAwait(false); ViewBag.NumberOfProcessingLeads = await leadsManager.GetNumberOfProcessingLeadsAsync(loggedInUser, permission).ConfigureAwait(false); ViewBag.NumberOfWonLeads = await leadsManager.GetNumberOfWonLeadsAsync(loggedInUser, permission).ConfigureAwait(false); ViewBag.NumberOfCustomer = await leadsManager.GetNumberOfCustomerAsync(loggedInUser, permission).ConfigureAwait(false); return(View(allLeadList)); }