public bool AssignDeptRep(int empid, string deptid) { try { drepo.AssignDeptRep(empid, deptid); Employee deptrep = erepo.FindEmpById(empid); Employee depthead = erepo.FindSupervisorByEmpId(deptrep.Id); //find collectionpoint Department dp = drepo.FindDeptbyRepID(deptrep.Id); CollectionPoint deptCP = crepo.GetDeptCollectionPoint(dp); EmailModel email = new EmailModel(); Task.Run(async() => { EmailTemplates.AssignDeptRepTemplate adt = new EmailTemplates.AssignDeptRepTemplate(deptrep, depthead, deptCP); email.emailTo = deptrep.Email; email.emailSubject = adt.subject; email.emailBody = adt.body; await mailservice.SendEmailAsync(email); }); return(true); } catch (Exception e) { throw e; } }