public async System.Threading.Tasks.Task CreateAsync(BL_TaskCreateRequest request) { //var taskList = await _repo.GetAllTasks(); var taskList = await _repo.GetTopTasks(); int taskId = 1; if (taskList.Count() != 0) { var lastTaskId = taskList.OrderByDescending(s => s.Id).Select(s => s.Id).FirstOrDefault(); taskId = lastTaskId + 1; } //Insert Task var tasks = _mapper.Map <BL_TaskCreateRequest, Tasks>(request); //tasks.FileNumber = taskId.ToString(); tasks.Type = "Suspense"; tasks.Status = "Open"; await _repo.InsertTask(tasks); var getDate = DateTime.Now; //Insert Pocsusername var taskPocs = new BlCreateTaskPocs { PoctaskId = taskId, Pocusername = request.UserName, PocdateAssigned = getDate, PocpersonalDate = getDate, //ParentUsername = request.UserName ParentUsername = "******", POClevel = 0, POCsort = "*" }; var taskPocsMapped = _mapper.Map <BlCreateTaskPocs, TaskPocs>(taskPocs); await _repo.InsertTaskPocs(taskPocsMapped); //Insert TaskUpdate var taskUpdate = new BlTaskUpdates { TaskId = taskId, DateUpdate = getDate, UserName = request.UserName }; var taskUpdateMapped = _mapper.Map <BlTaskUpdates, TaskUpdates>(taskUpdate); await _repo.InsertTaskUpdates(taskUpdateMapped); //Email Funtionality Email Email = new Email(); MailContentModel mailSettings = Email.EmailSettings; // Send success notification... mailSettings.MailSubject = "Test Test Test"; string details = "~~ Inbound Acknowledgement File Processed Successfully ~~"; details += Environment.NewLine; details += string.Format("Process Date/Time: {0:MM-dd-yyyy hh:mm:ss tt}, ", DateTime.Now); details += Environment.NewLine; details += string.Format("Record Count:{0}", 20); mailSettings.MailBody = details; mailSettings.MailTo = "*****@*****.**"; EmailUtility.SendMailMessage(mailSettings); }