public bool Update(ViewModel.UpcomingEvents upcomingEvents)
        {

            var account = new Intranet.Common.AccountInfo();
            var fullName = account.GetFullName();



            var entityEvent = new UpcomingEvents();
            TimeSpan interval = TimeSpan.Parse(upcomingEvents.EventTime);
            entityEvent.Id = upcomingEvents.Id;
            entityEvent.LastUpdatedDate = DateTime.Now;
            entityEvent.LastUpdatedBy = fullName;
            entityEvent.CreatedDate = upcomingEvents.CreatedDate;
            entityEvent.IsDeleted = false;
            entityEvent.CreatedBy = upcomingEvents.CreatedBy;
            entityEvent.Title = upcomingEvents.Title;
            entityEvent.Location = upcomingEvents.Location;
            entityEvent.Organizers = upcomingEvents.Organizers;
            entityEvent.StartDate = upcomingEvents.StartDate;
            entityEvent.EndDate = upcomingEvents.EndDate;
            entityEvent.Venue = upcomingEvents.Venue;
            entityEvent.Duration = upcomingEvents.Duration;
            entityEvent.IsActive = upcomingEvents.IsActive;
            entityEvent.Date = Convert.ToDateTime(upcomingEvents.Date.ToShortDateString()).Add(interval);
            entityEvent.ApproverName = upcomingEvents.ApproverName;
            entityEvent.IsApproved = upcomingEvents.IsApproved;

            if (!upcomingEvents.IsApproved)
            {
                var notificationExited = NotificationService.GetAllNotificationByRecoedId("Event",
                    upcomingEvents.Id);
                NotificationService.DeleteNotification(notificationExited);
                var notification = new Notification()
                {
                    ReciverName = upcomingEvents.ApproverName,
                    SenderName = fullName,
                    CreatedBy = upcomingEvents.CreatedBy,
                    LastUpdatedBy = fullName,
                    LastUpdatedDate = DateTime.Now,
                    CreatedDate = upcomingEvents.CreatedDate,
                    RecordId = upcomingEvents.Id,
                    ModuleName = "Event",
                    IsApproved = false
                };
                NotificationService.InsertNotification(notification);
                SendStatusUpdateEmail(upcomingEvents, upcomingEvents.ApproverName, false, upcomingEvents.CreatedBy);
            }
            else
            {
                var notificationExited = NotificationService.GetAllNotificationByRecoedId("Event",
                       upcomingEvents.Id);
                if (notificationExited != null)
                    NotificationService.DeleteNotification(notificationExited);

                var notification = new Notification()
                {
                    ReciverName = upcomingEvents.CreatedBy,
                    SenderName = upcomingEvents.ApproverName,
                    CreatedBy = upcomingEvents.CreatedBy,
                    LastUpdatedBy = fullName,
                    LastUpdatedDate = DateTime.Now,
                    CreatedDate = upcomingEvents.CreatedDate,
                    RecordId = upcomingEvents.Id,
                    ModuleName = "Event",
                    IsApproved = true
                };
                NotificationService.InsertNotification(notification);
                SendStatusUpdateEmail(upcomingEvents, upcomingEvents.CreatedBy, false, upcomingEvents.CreatedBy);
            }




            return UpcomingEventsService.UpdateUpcomingEvents(entityEvent);
            
        }
        public bool Add(ViewModel.UpcomingEvents upcomingEvents)
        {

            var account = new Intranet.Common.AccountInfo();
            var entityEvent = new UpcomingEvents();
            TimeSpan interval = TimeSpan.Parse(upcomingEvents.EventTime); 
            var fullName = account.GetFullName();
            entityEvent.IsDeleted = false;
            entityEvent.CreatedDate = DateTime.Now;
            entityEvent.CreatedBy = fullName;
            entityEvent.LastUpdatedDate = DateTime.Now;
            entityEvent.LastUpdatedBy = fullName;
            entityEvent.Title = upcomingEvents.Title;
            entityEvent.Location = upcomingEvents.Location;
            entityEvent.Organizers = upcomingEvents.Organizers;
            entityEvent.StartDate = upcomingEvents.StartDate;
            entityEvent.EndDate = upcomingEvents.EndDate;
            entityEvent.Venue = upcomingEvents.Venue;
            entityEvent.Duration = upcomingEvents.Duration;
            entityEvent.IsActive = upcomingEvents.IsActive;
            entityEvent.Date = upcomingEvents.Date.Add(interval);
            entityEvent.ApproverName = upcomingEvents.ApproverName;
            entityEvent.IsApproved = upcomingEvents.IsApproved;


            var insertedRec = UpcomingEventsService.InsertUpcomingEvents(entityEvent);
            //to do change the logic

            var notification = new Notification()
            {
                ReciverName = upcomingEvents.ApproverName,
                SenderName = fullName,
                CreatedBy = fullName,
                LastUpdatedBy = fullName,
                LastUpdatedDate = DateTime.Now,
                CreatedDate = DateTime.Now,
                RecordId = insertedRec.Id,
                ModuleName = "Event",
                IsApproved = false
            };
            NotificationService.InsertNotification(notification);
            SendStatusUpdateEmail(upcomingEvents, upcomingEvents.ApproverName, true, fullName);


            return true;
            
        }
         public bool Update(VacancyViewModel vacancy)
        {

            var account = new Intranet.Common.AccountInfo();
            var fullName = account.GetFullName();

             var vac = new Vacancy()
             {
                 Id = vacancy.Id,
                 Location = vacancy.Location,
                 Url = vacancy.Url,
                 IsActive = vacancy.IsActive,
                 ApproverName = vacancy.ApproverName,
                 CreatedBy = vacancy.CreatedBy,
                 CreatedDate = vacancy.CreatedDate,
                 IsDeleted = false,
                 LastUpdatedDate = DateTime.Now,
                 LastUpdatedBy = fullName,
                 IsApproved =vacancy.IsApproved

             };
             VacancyService.UpdateVacancy(vac);

             if (!vacancy.IsApproved)
             {
                 var notificationExited = NotificationService.GetAllNotificationByRecoedId("Vacancies",
                     vacancy.Id);
                 if(notificationExited!=null)
                    NotificationService.DeleteNotification(notificationExited);

                 var notification = new Notification()
                 {
                     ReciverName = vacancy.ApproverName,
                     SenderName = fullName,
                     CreatedBy = vacancy.CreatedBy,
                     LastUpdatedBy = fullName,
                     LastUpdatedDate = DateTime.Now,
                     CreatedDate = vacancy.CreatedDate,
                     RecordId = vacancy.Id,
                     ModuleName = "Vacancies",
                     IsApproved = false
                 };
                 NotificationService.InsertNotification(notification);
                 SendStatusUpdateEmail(vacancy, vacancy.ApproverName, false, vacancy.CreatedBy);
             }
             else
             {
                 var notificationExited = NotificationService.GetAllNotificationByRecoedId("Vacancies",
                       vacancy.Id);
                 if (notificationExited != null)
                    NotificationService.DeleteNotification(notificationExited);

                 var notification = new Notification()
                 {
                     ReciverName = vacancy.CreatedBy,
                     SenderName = vacancy.ApproverName,
                     CreatedBy = vacancy.CreatedBy,
                     LastUpdatedBy = fullName,
                     LastUpdatedDate = DateTime.Now,
                     CreatedDate = vacancy.CreatedDate,
                     RecordId = vacancy.Id,
                     ModuleName = "Vacancies",
                     IsApproved = true
                 };
                 NotificationService.InsertNotification(notification);
                 SendStatusUpdateEmail(vacancy, vacancy.CreatedBy, false, vacancy.CreatedBy);
             }



             return true;

        }
        public bool Add(ViewModel.AnnouncementViewModel announcement)
        {

            var account = new Intranet.Common.AccountInfo();
            var fullName = account.GetFullName();
            var ann = new HomePageAnnouncement()
            {
                AnnouncementContent = announcement.AnnouncementContent,
                StartDate = announcement.StartDate,
                EndDate = announcement.EndDate,
                IsApproved = false,
                IsActive = announcement.IsActive,
                ApproverName = announcement.ApproverName,
                IsDeleted = false,
                CreatedDate = DateTime.Now,
                CreatedBy = fullName,
                LastUpdatedDate = DateTime.Now,
                LastUpdatedBy = fullName,
            };

            var insertedRec = AnnouncementService.InsertHomePageAnnouncement(ann);
            var notification = new Notification()
            {
                ReciverName = announcement.ApproverName,
                SenderName = fullName,
                CreatedBy = fullName,
                LastUpdatedBy = fullName,
                LastUpdatedDate = DateTime.Now,
                CreatedDate = DateTime.Now,
                RecordId = insertedRec.Id,
                ModuleName = "Announcement",
                IsApproved = false
            };
            NotificationService.InsertNotification(notification);
            SendStatusUpdateEmail(announcement, announcement.ApproverName, true, fullName);

            return true;
        }
        public bool Update(ViewModel.AnnouncementViewModel announcement)
        {

            var account = new Intranet.Common.AccountInfo();
            var fullName = account.GetFullName();

            var ann = new HomePageAnnouncement()
            {
                Id = announcement.Id,
                AnnouncementContent = announcement.AnnouncementContent,
                StartDate = announcement.StartDate,
                EndDate = announcement.EndDate,
                IsApproved = announcement.IsApproved,
                IsActive = announcement.IsActive,
                ApproverName = announcement.ApproverName,
                IsDeleted = false,
                CreatedDate = announcement.CreatedDate,
                CreatedBy = announcement.CreatedBy,
                LastUpdatedDate = DateTime.Now,
                LastUpdatedBy = fullName,
                
            };

            var updatedRec = AnnouncementService.UpdateHomePageAnnouncement(ann);

            if (!announcement.IsApproved)
            {
                var notificationExited = NotificationService.GetAllNotificationByRecoedId("Announcement",
                    announcement.Id);
                NotificationService.DeleteNotification(notificationExited);
                var notification = new Notification()
                {
                    ReciverName = announcement.ApproverName,
                    SenderName = fullName,
                    CreatedBy = announcement.CreatedBy,
                    LastUpdatedBy = fullName,
                    LastUpdatedDate = DateTime.Now,
                    CreatedDate = announcement.CreatedDate,
                    RecordId = announcement.Id,
                    ModuleName = "Announcement",
                    IsApproved = false
                };
                NotificationService.InsertNotification(notification);
                SendStatusUpdateEmail(announcement, announcement.ApproverName, false, announcement.CreatedBy);
            }
            else
            {
                var notificationExited = NotificationService.GetAllNotificationByRecoedId("Announcement",
                      announcement.Id);
                if (notificationExited != null)
                    NotificationService.DeleteNotification(notificationExited);

                var notification = new Notification()
                {
                    ReciverName = announcement.CreatedBy,
                    SenderName = announcement.ApproverName,
                    CreatedBy = announcement.CreatedBy,
                    LastUpdatedBy = fullName,
                    LastUpdatedDate = DateTime.Now,
                    CreatedDate = announcement.CreatedDate,
                    RecordId = announcement.Id,
                    ModuleName = "Announcement",
                    IsApproved = true
                };
                NotificationService.InsertNotification(notification);
                SendStatusUpdateEmail(announcement, announcement.CreatedBy, false, announcement.CreatedBy);
            }

            return AnnouncementService.UpdateHomePageAnnouncement(ann);

        }
        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);

        }