private Neos.Data.Job SaveJobInfo() { UserMessageRepository messageRepo = new UserMessageRepository(); JobRepository jobRepo = new JobRepository(); Neos.Data.Job job = new Neos.Data.Job(); if (!string.IsNullOrEmpty(Request.QueryString["JobId"])) //edit { job = jobRepo.FindOne(new Job(Int32.Parse(Request.QueryString["JobId"]))); if (job != null) { string responsibleUser = job.CareerManager; job = SetInfoForJob(job); jobRepo.Update(job); if (responsibleUser != ddlResponsible.SelectedValue) // in case select another responsible user { if (job.RemindDate.HasValue && job.ExpiredDate.HasValue) { UserMessage message = messageRepo.FindMessagesByRef(job.JobID.ToString()); if (message != null) { message.UserID = job.CareerManager; messageRepo.Update(message); } } } } } else //edit { job = SetInfoForJob(job); job.CreatedDate = DateTime.Now; jobRepo.Insert(job); //insert a notification message if (job.RemindDate.HasValue && job.ExpiredDate.HasValue) { UserMessage message = new UserMessage(); message.UserID = ddlResponsible.SelectedValue; message.Type = UserMessageType.JobResponsibility; message.Subject = ResourceManager.GetString("message.JobReminderSubject"); message.MessageContent = string.Format(ResourceManager.GetString("message.JobReminderContent"), job.ExpiredDate.Value.ToString("dd/MM/yyyy hh:mm tt"), "JobProfile.aspx?JobId=" + job.JobID); message.RemindDate = job.RemindDate; message.CreatedDate = DateTime.Now; message.IsUnread = true; message.RefID = job.JobID.ToString(); messageRepo.Insert(message); } } return job; }
private void UpdateMessagesStatus(string status) { UserMessageRepository messageRepo = new UserMessageRepository(); foreach (GridDataItem selectedItem in MessageGrid.SelectedItems) { TableCell messageIDCell = selectedItem["MessageID"]; if (messageIDCell != null) { int messageID = Convert.ToInt32(messageIDCell.Text); UserMessage message = messageRepo.FindOne(new UserMessage(messageID)); if (message != null) { if (status == "MarkAsRead") { message.IsUnread = false; } else if (status == "MarkAsUnread") { message.IsUnread = true; } messageRepo.Update(message); } } } MessageGrid.Rebind(); }