public bool SendMailFromMyTUIProfile(string userid, string templateName) { var staff = _staffRepo.GetByStaffId(userid); var templates = _mailRepos.GetTemplate(templateName); var mailReturn = SendMail(templates, staff); return(true); }
public async Task <bool> ResignUser([FromBody] ResignViewModel resignModel) //From StaffDoc { DateTime?ParsedFromDate = resignModel.AppDate; DateTime TodayDate = DateTime.Now; UserModel UserName = _userRepo.GetUser(); if (ParsedFromDate <= TodayDate) { // ok this is a full abscense with status change in Staff the full Monty var res1 = await _resignRepo.ResignUser(resignModel); var res2 = _resignRepo.UpdateUser(resignModel.StaffID); if (res1) { if (res2) { var History = new HistoryModel(); // Add to History all actions of relevancy { History.StaffID = resignModel.StaffID; History.HistoryDate = resignModel.AppDate; History.HistoryAction = "RESIGNED"; History.HistoryLocation = "Some Destínation"; History.ApplicationType = "Resign"; History.DateModified = DateTime.UtcNow; History.Status = "Received"; History.HistoryWho = UserName.UserName; History.JobTitleWhenResigned = resignModel.JobTitleWhenResigned; // History.HistoryWho = System.Security.Principal.WindowsIdentity.GetCurrent().Name; }; _historyRepo.UpdateHistoryResign(History); var staff = _staffRepos.GetByStaffIdResign(resignModel.StaffID); var templates = _mailRepos.GetTemplate("ResignMail"); await _mailRepos.SendMailStaff(templates, staff); // with full data for the Placement team if (resignModel.ManagerReason != "Dismissed") { var mailReturn = _mailRepos.SendMail(templates, staff); // to the Staff } _resignRepo.DeleteUserInPosAssign(resignModel.StaffID); return(true); } } } else { // just create dates and abscense entry the not so full Monty var res1 = await _resignRepo.ResignUser(resignModel); if (res1) { var staff = _staffRepos.GetByStaffIdResign(resignModel.StaffID); var templates = _mailRepos.GetTemplate("ResignMail"); await _mailRepos.SendMailStaff(templates, staff); // with full data for the Placement team if (resignModel.ManagerReason != "Dismissed") { var mailReturn = _mailRepos.SendMail(templates, staff); // to the Staff } return(true); } } return(false); }