public bool Add(ViewModel.NewJoineeViewModel newJoinee) { var account = new Intranet.Common.AccountInfo(); var fullName = account.GetFullName(); var nj = new NewJoinees() { FirstName = newJoinee.FirstName, LastName = newJoinee.LastName, Department = newJoinee.Department, Role = newJoinee.Role, Location = newJoinee.Location, DateOfJoining = newJoinee.DateOfJoining, StartDate = newJoinee.StartDate, EndDate = newJoinee.EndDate, IsActive = newJoinee.IsActive, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = fullName, LastUpdatedDate = DateTime.Now, LastUpdatedBy = fullName, ApproverName = newJoinee.ApproverName }; var insertedRec=NewJoineeService.InsertNewJoinee(nj); var notification = new Notification() { ReciverName = newJoinee.ApproverName, SenderName = fullName, CreatedBy = fullName, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = DateTime.Now, RecordId = insertedRec.Id, ModuleName = "NewJoinee", IsApproved = false }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(newJoinee, newJoinee.ApproverName, true, fullName); return true; }
public bool Update(ViewModel.NewJoineeViewModel newJoinee) { var account = new Intranet.Common.AccountInfo(); var fullName = account.GetFullName(); var nj = new NewJoinees() { Id = newJoinee.Id, FirstName = newJoinee.FirstName, LastName = newJoinee.LastName, Department = newJoinee.Department, Role = newJoinee.Role, Location = newJoinee.Location, DateOfJoining = newJoinee.DateOfJoining, StartDate = newJoinee.StartDate, EndDate = newJoinee.EndDate, IsActive = newJoinee.IsActive, IsDeleted = false, CreatedDate =newJoinee.CreatedDate, CreatedBy = newJoinee.CreatedBy, LastUpdatedDate = DateTime.Now, LastUpdatedBy = fullName, ApproverName = newJoinee.ApproverName, IsApproved = newJoinee.IsApproved }; NewJoineeService.UpdateNewJoinee(nj); if (!newJoinee.IsApproved) { var notificationExited = NotificationService.GetAllNotificationByRecoedId("NewJoinee", newJoinee.Id); NotificationService.DeleteNotification(notificationExited); var notification = new Notification() { ReciverName = newJoinee.ApproverName, SenderName = fullName, CreatedBy = newJoinee.CreatedBy, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = newJoinee.CreatedDate, RecordId = newJoinee.Id, ModuleName = "NewJoinee", IsApproved = false }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(newJoinee, newJoinee.ApproverName, false, newJoinee.CreatedBy); } else { var notificationExited = NotificationService.GetAllNotificationByRecoedId("NewJoinee", newJoinee.Id); if (notificationExited != null) NotificationService.DeleteNotification(notificationExited); var notification = new Notification() { ReciverName = newJoinee.CreatedBy, SenderName = newJoinee.ApproverName, CreatedBy = newJoinee.CreatedBy, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = newJoinee.CreatedDate, RecordId = newJoinee.Id, ModuleName = "NewJoinee", IsApproved = true }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(newJoinee, newJoinee.CreatedBy, false, newJoinee.CreatedBy); } return NewJoineeService.UpdateNewJoinee(nj); }