public ActionResult NotificationRead(int id) { try { IEnumerable <NotificationsViewModel> ntd = _notifications.SingleNotification(id); NotificationsDTOs notif = new NotificationsDTOs(); notif.NotificationId = Convert.ToInt32(ntd.FirstOrDefault().NotificationID); notif.NotificationMessage = ntd.FirstOrDefault().Message; notif.NotificationReceiverId = Convert.ToInt32(ntd.FirstOrDefault().ReceiverID); notif.NotificationReceiverType = ntd.FirstOrDefault().ReceiverType; notif.NotificationDate = Convert.ToDateTime(ntd.FirstOrDefault().Date); notif.NotificationSubject = ntd.FirstOrDefault().Subject; notif.NotificationReadDate = DateTime.Now; notif.NotificationDetailURL = ntd.FirstOrDefault().DetailUrl; _notifications.UpdateNotification(notif); if (String.IsNullOrEmpty(notif.NotificationDetailURL)) { return(RedirectToAction("Notifications", "User")); } else { return(Redirect(notif.NotificationDetailURL)); } } catch (Exception ex) { return(RedirectToAction("Notifications", "User")); } }
public int NotificationLeaveRequestRecommend(LeaveApplicationViewModel Lat) { EmployeeDetailsViewModel user = _employeeService.GetEmployeeDetails(Lat.LeaveEmpCode); EmployeeDetailsViewModel recomend = _employeeService.GetEmployeeDetails(Convert.ToInt32(Lat.LeaveRecommenderEmpcode)); EmployeeDetailsViewModel approver = _employeeService.GetEmployeeDetails(Convert.ToInt32(Lat.LeaveApproverEmpcode)); if (Lat.RecommendStatus == 2) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(Lat.LeaveEmpCode); ntd.NotificationSubject = "Recommender approve your Leave Request"; ntd.NotificationMessage = "Your " + Lat.LeaveTypeName + " requested on " + Lat.LeaveAppliedDate.ToString("yyyy,MMM dd") + " is Recommended by " + recomend.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/leave/detail/" + Lat.LeaveId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationapprover NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = approver.Code; ntf.NotificationSubject = "Leave Requested to approve"; ntf.NotificationMessage = user.Name + " Slected you as Approver as this leave request is already been recommened by " + recomend.Name + ".Please confirm the request "; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/leaveapplication/approve/" + Lat.LeaveId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion } else if (Lat.RecommendStatus == 3) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = Lat.LeaveTypeName + " request rejected by " + recomend.Name; ntd.NotificationMessage = "Sorry!! Your " + Lat.LeaveTypeName + " applied on " + Lat.LeaveAppliedDate.ToString("yyyy,MMM dd") + " is rejected by " + recomend.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/leave/detail/" + Lat.LeaveId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion } return(0); }
public static Notification ConvertRespondentInfoFromDTO(this NotificationsDTOs ntd) { Mapper.CreateMap <NotificationsDTOs, Notification>().ConvertUsing( m => { return(new Notification { NotificationDate = m.NotificationDate, NotificationDetailURL = m.NotificationDetailURL, NotificationId = m.NotificationId, NotificationMessage = m.NotificationMessage, NotificationSubject = m.NotificationSubject, NotificationReceiverType = m.NotificationReceiverType, NotificationReadDate = m.NotificationReadDate, NotificationReceiverId = m.NotificationReceiverId }); }); return(Mapper.Map <NotificationsDTOs, Notification>(ntd)); }
public int NotificationRequestAttendance(AttendanceRequestDTO atd) { EmployeeDetailsViewModel user = _employeeService.GetEmployeeDetails(atd.RequestEmpCode); EmployeeDetailsViewModel recomend = _employeeService.GetEmployeeDetails(Convert.ToInt32(atd.RecommendarEmpCode)); #region Notification NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(atd.RecommendarEmpCode); ntd.NotificationSubject = "Recommender for Attendance request"; ntd.NotificationReceiverType = "E"; ntd.NotificationMessage = user.Name + " Selected you as a Recommender. Please confirm the request"; ntd.NotificationDetailURL = "/user/attendancerequest/recommendlist"; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Email string emailType = "Email"; EmailServices.Message msg = new EmailServices.Message(); htmlReader reader = new htmlReader(); List <string> recipient = new List <string>() { recomend.Email }; msg.Subject = "Attendnace request Recommend"; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = recomend.Name, Descriptions = user.Name + " has requested attendance for " + atd.RequestType + " on " + atd.RequestedDate + ". Please visit the link below and confirm the request ", FullName = user.Name, Title = "Attendance Request for recommendation", Url = baseUrl + "/user/attendancerequest/recommendlist" }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailType); EmailServices.Notify(recipient, msg); #endregion return(0); }
public int NoftificationLeaveRequestApprove(LeaveApplicationViewModel lat) { EmployeeDetailsViewModel user = _employeeService.GetEmployeeDetails(lat.LeaveEmpCode); EmployeeDetailsViewModel recomend = _employeeService.GetEmployeeDetails(Convert.ToInt32(lat.LeaveRecommenderEmpcode)); EmployeeDetailsViewModel approver = _employeeService.GetEmployeeDetails(Convert.ToInt32(lat.LeaveApproverEmpcode)); if (lat.LeaveStatus == 2) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = lat.LeaveTypeName + " Request has been approved"; ntd.NotificationMessage = lat.LeaveTypeName + " requested on " + lat.LeaveAppliedDate.ToString("yyyy,MM dd") + " is Approved by " + approver.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/leave/detail/" + lat.LeaveId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationrecommender NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = recomend.Code; ntf.NotificationSubject = "Recommended Leave request has been approved "; ntf.NotificationMessage = lat.LeaveTypeName + " requested by" + user.Name + " on " + lat.LeaveAppliedDate.ToString("yyyy-MMM-dd") + " is aproved by" + approver.Name; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/leaveapplication/recommend/" + lat.LeaveId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion } else if (lat.LeaveStatus == 3) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = "Approver reject your " + lat.LeaveTypeName + " request"; ntd.NotificationMessage = lat.LeaveTypeName + " requested on " + lat.LeaveAppliedDate.ToString("yyyy,MM dd") + " is Rejected by " + approver.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/leave/detail/" + lat.LeaveId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationrecommender NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = recomend.Code; ntf.NotificationSubject = "Recommended Leave request has been Rejected "; ntf.NotificationMessage = lat.LeaveTypeName + " Request of " + user.Name + " requested on " + lat.LeaveAppliedDate.ToString("yyyy,MM dd") + " is rejected by" + approver.Name; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/leave/detail/" + lat.LeaveId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion } return(0); }
public int NotificationApproveAttendance(AttendanceRequestDTO atd) { EmployeeDetailsViewModel user = _employeeService.GetEmployeeDetails(atd.RequestEmpCode); EmployeeDetailsViewModel recomend = _employeeService.GetEmployeeDetails(Convert.ToInt32(atd.RecommendarEmpCode)); EmployeeDetailsViewModel approver = _employeeService.GetEmployeeDetails(Convert.ToInt32(atd.ApproverEmpCode)); if (atd.ApproveStatus == 2) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = "Approver approve your Attendnace"; ntd.NotificationMessage = "Attendance you requested on " + atd.RequestedDate + " is Approved by " + approver.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/attendancerequest/AttendanceDetail/" + atd.RequestId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationrecommender NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = recomend.Code; ntf.NotificationSubject = "Approved attendance request"; ntf.NotificationMessage = "Attendance requested by" + user.Name + " on " + atd.RequestedDate + "is aproved by" + approver.Name; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/attendancerequest/recommend/" + atd.RequestId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion } else if (atd.ApproveStatus == 3) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = "Approver reject your Attendnace request"; ntd.NotificationMessage = "Attendance requested by" + user.Name + " on " + atd.RequestedDate + "is rejected by" + approver.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/attendancerequest/AttendanceDetail/" + atd.RequestId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationrecommender NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = recomend.Code; ntf.NotificationSubject = "Approver Rejected attendance request of " + user.Name; ntf.NotificationMessage = "Attendance requested for " + atd.RequestType + "requested on " + atd.RequestedDate + " is rejected by" + approver.Name; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/attendancerequest/recommend/" + atd.RequestId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion } #region Emailuser string emailType = "Email"; EmailServices.Message msg = new EmailServices.Message(); htmlReader reader = new htmlReader(); List <string> recipient = new List <string>() { user.Email }; if (atd.ApproveStatus == 2) { msg.Subject = "Approver confirm Attendnace request"; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = user.Name, Descriptions = "Attendance requested on " + atd.RequestedDate + " for " + atd.RequestType + " is approved by " + approver.Name + " for more detail follow the link below", FullName = recomend.Name, Title = "Approver confirm Attendnace request for " + atd.RequestType, Url = baseUrl + "user/attendancerequest/AttendanceDetail/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailType); EmailServices.Notify(recipient, msg); } else if (atd.ApproveStatus == 3) { msg.Subject = "Approver Rejected Attendnace request"; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = user.Name, Descriptions = "Attendance requested on " + atd.RequestedDate + " for " + atd.RequestType + " is rejected by " + approver.Name + " for more detail follow the link below", FullName = recomend.Name, Title = "Rejected Attendnace request for " + atd.RequestType, Url = baseUrl + "/user/attendancerequest/AttendanceDetail/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailType); EmailServices.Notify(recipient, msg); } #endregion #region Emailapprover string emailTypeapprover = "Email"; EmailServices.Message msgapprover = new EmailServices.Message(); htmlReader readerapprover = new htmlReader(); List <string> listapprover = new List <string>() { recomend.Email }; if (atd.RecommendStatus == 2) { msg.Subject = "Attendnace request approved of " + user.Name; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = user.Name, Descriptions = "Attendnace you recommended on " + atd.RecommendStatusDate + " of " + user.Name + " is aproved by " + approver.Name + " on " + DateTime.Now + ". Please visit link below for details", FullName = recomend.Name, Title = "Attendnace request of " + user.Name + " for " + atd.RequestType + " is approved ", Url = baseUrl + "/user/attendancerequest/recommend/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailTypeapprover); EmailServices.Notify(listapprover, msgapprover); } else if (atd.RecommendStatus == 3) { msg.Subject = " Attendnace request rejected of " + user.Name; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = recomend.Name, Descriptions = "Attendnace you recommended on " + atd.RecommendStatusDate + " of " + user.Name + " is rejected by " + approver.Name + " on " + DateTime.Now + ". Please visit link below for details", FullName = recomend.Name, Title = "Attendnace request of " + user.Name + " for " + atd.RequestType + " is approved ", Url = baseUrl + "/user/attendancerequest/recommend/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailTypeapprover); EmailServices.Notify(listapprover, msgapprover); } #endregion return(0); }
public int NotificationRecommendAttendance(AttendanceRequestDTO atd) { EmployeeDetailsViewModel user = _employeeService.GetEmployeeDetails(atd.RequestEmpCode); EmployeeDetailsViewModel recomend = _employeeService.GetEmployeeDetails(Convert.ToInt32(atd.RecommendarEmpCode)); EmployeeDetailsViewModel approver = _employeeService.GetEmployeeDetails(Convert.ToInt32(atd.ApproverEmpCode)); if (atd.RecommendStatus == 2) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(atd.RequestEmpCode); ntd.NotificationSubject = "Recommender approve your Attendnace"; ntd.NotificationMessage = "Your attendnace request on " + atd.RequestedDate + " is Recommended by " + recomend.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/attendancerequest/AttendanceDetail/" + atd.RequestId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion #region Notificationapprover NotificationsDTOs ntf = new NotificationsDTOs(); ntf.NotificationDate = DateTime.Now; ntf.NotificationReceiverId = approver.Code; ntf.NotificationSubject = "Attendnace Requested to approve"; ntf.NotificationMessage = user.Name + " Slected you as Approver as this request is already been recommened by " + recomend.Name + ".Please confirm the request "; ntf.NotificationReceiverType = "E"; ntf.NotificationDetailURL = "/user/attendancerequest/recommend/" + atd.RequestId; ntf.NotificationReadDate = null; _notifications.InsertNotification(ntf); #endregion #region Emailapprover string emailTypeapprover = "Email"; EmailServices.Message mgs_r = new EmailServices.Message(); htmlReader reader_r = new htmlReader(); List <string> receiver = new List <string>() { approver.Email }; mgs_r.Subject = "Attendnace request for Approve "; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = approver.Name, Descriptions = user.Name + " has request attendance for" + atd.RequestType + " on " + atd.RequestedDate + ". Please confirm the request as this request is already been recommended by " + recomend.Name + " on " + DateTime.Now + " Please follow the link below for more detail.", FullName = recomend.Name, Title = "Attendance Request for approve", Url = baseUrl + "/user/attendancerequest/approved/" + atd.RequestId.ToString() }; mgs_r.Body = reader_r.GetHtmlBodyTemplate(emailTemplateData, emailTypeapprover); EmailServices.Notify(receiver, mgs_r); #endregion } else if (atd.RecommendStatus == 3) { #region NotificationUser NotificationsDTOs ntd = new NotificationsDTOs(); ntd.NotificationDate = DateTime.Now; ntd.NotificationReceiverId = Convert.ToInt32(user.Code); ntd.NotificationSubject = "Attendance request rejected by " + recomend.Name; ntd.NotificationMessage = "Sorry!! Your attendnace request on " + atd.RequestedDate + " is rejected by " + recomend.Name; ntd.NotificationReceiverType = "E"; ntd.NotificationDetailURL = "/user/attendancerequest/AttendanceDetail/" + atd.RequestId; ntd.NotificationReadDate = null; _notifications.InsertNotification(ntd); #endregion } #region Emailuser string emailType = "Email"; EmailServices.Message msg = new EmailServices.Message(); htmlReader reader = new htmlReader(); List <string> recipient = new List <string>() { user.Email }; if (atd.RecommendStatus == 2) { msg.Subject = "Recommender for Attendnace request"; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = user.Name, Descriptions = "Attendance you requested on " + atd.RequestedDate + " for " + atd.RequestType + " has been accepted by " + recomend.Name + " on " + DateTime.Now + ". Please visit the link below for details", FullName = recomend.Name, Title = "Recommend Attendance Request", Url = baseUrl + "user/attendancerequest/AttendanceDetail/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailType); EmailServices.Notify(recipient, msg); } else if (atd.RecommendStatus == 3) { msg.Subject = "Attendance request rejected by Recommender"; EmailTemplateModel emailTemplateData = new EmailTemplateModel() { UserName = user.Name, Descriptions = "Attendance you requested on " + atd.RequestedDate + " for " + atd.RequestType + " has been rejected by " + recomend.Name + " on " + DateTime.Now + ". Please visit the link below for details", FullName = recomend.Name, Title = "Recommend Attendance Request", Url = baseUrl + "user/attendancerequest/AttendanceDetail/" + atd.RequestId.ToString() }; msg.Body = reader.GetHtmlBodyTemplate(emailTemplateData, emailType); EmailServices.Notify(recipient, msg); } #endregion return(0); }
public NotificationsDTOs InsertNotification(NotificationsDTOs ntd) { Notification nttd = NotificationRequestFormatter.ConvertRespondentInfoFromDTO(ntd); return(NotificationRequestFormatter.ConvertRespondentToDTO(_unitOfWork.NotificationRepository.Create(nttd))); }
public int UpdateNotification(NotificationsDTOs ntd) { Notification ntf = NotificationRequestFormatter.ConvertRespondentInfoFromDTO(ntd); return(_unitOfWork.NotificationRepository.Update(ntf)); }