コード例 #1
0
        /// <summary>
        /// Add or Update CaseActionNew to database
        /// </summary>
        /// <param name="CaseActionNew">data to save</param>
        public void InsertOrUpdate(CaseActionNew CaseActionNew)
        {
            bool isNew = false;

            if (CaseActionNew.CaseMemberID > 0 && !CaseActionNew.OLDCaseMemberID.HasValue)
            {
                CaseActionNew.ServiceProviderID        = null;
                CaseActionNew.WorkerID                 = null;
                CaseActionNew.AssigneeOther            = null;
                CaseActionNew.SubjectMatterExpertOther = null;
            }
            if (CaseActionNew.ServiceProviderID > 0 && !CaseActionNew.OLDServiceProviderID.HasValue)
            {
                CaseActionNew.CaseMemberID             = null;
                CaseActionNew.FamilyAgreeToAction      = false;
                CaseActionNew.WorkerID                 = null;
                CaseActionNew.AssigneeOther            = null;
                CaseActionNew.SubjectMatterExpertOther = null;
            }
            if (CaseActionNew.WorkerID > 0 && !CaseActionNew.OLDWorkerID.HasValue)
            {
                CaseActionNew.ServiceProviderID   = null;
                CaseActionNew.CaseMemberID        = null;
                CaseActionNew.FamilyAgreeToAction = false;
                CaseActionNew.AssigneeOther       = null;
            }
            if (CaseActionNew.WorkerID > 0 || CaseActionNew.CaseMemberID > 0 || (CaseActionNew.ServiceProviderID > 0 && CaseActionNew.ServiceProviderID != 56))
            {
                CaseActionNew.AssigneeOther            = null;
                CaseActionNew.SubjectMatterExpertOther = null;
            }
            if (!string.IsNullOrEmpty(CaseActionNew.SubjectMatterExpertOther))
            {
                CaseActionNew.AssigneeOther = null;
            }
            if (!string.IsNullOrEmpty(CaseActionNew.AssigneeOther))
            {
                CaseActionNew.SubjectMatterExpertOther = null;
            }
            if (!string.IsNullOrEmpty(CaseActionNew.AssigneeOther) && string.IsNullOrEmpty(CaseActionNew.OLDAssigneeOther))
            {
                CaseActionNew.ServiceProviderID = null;
                CaseActionNew.CaseMemberID      = null;
                CaseActionNew.WorkerID          = null;
            }
            if (!string.IsNullOrEmpty(CaseActionNew.SubjectMatterExpertOther) && string.IsNullOrEmpty(CaseActionNew.OLDSubjectMatterExpertOther))
            {
                CaseActionNew.ServiceProviderID = null;
                CaseActionNew.CaseMemberID      = null;
                CaseActionNew.WorkerID          = null;
            }
            if (CaseActionNew.ServiceProviderID == 0)
            {
                CaseActionNew.ServiceProviderID = null;
            }
            if (CaseActionNew.WorkerID == 0)
            {
                CaseActionNew.WorkerID = null;
            }

            if (!string.IsNullOrEmpty(CaseActionNew.ServiceProviderOther))
            {
                CaseActionNew.AssigneeOther = CaseActionNew.ServiceProviderOther;
            }

            //if (!string.IsNullOrEmpty(CaseActionNew.SubjectMatterExpertOther))
            //{
            //    CaseActionNew.AssigneeOther = CaseActionNew.SubjectMatterExpertOther;
            //}

            CaseActionNew.LastUpdateDate = DateTime.Now;
            if (CaseActionNew.ID == default(int))
            {
                isNew = true;
                //set the date when this record was created
                CaseActionNew.CreateDate = CaseActionNew.LastUpdateDate;
                //set the id of the worker who has created this record
                CaseActionNew.CreatedByWorkerID = CaseActionNew.LastUpdatedByWorkerID;
                //add a new record to database
                context.CaseActionNew.Add(CaseActionNew);
            }
            else
            {
                //update an existing record to database
                context.Entry(CaseActionNew).State = System.Data.Entity.EntityState.Modified;
            }
            Save();

            if (CaseActionNew.WorkerID.HasValue && CaseActionNew.WorkerID.Value > 0)
            {
                string     caseLink   = "/CaseManagement/CaseActionNew/Index?CaseID=" + CaseActionNew.CaseID + "&CaseMemberID=" + CaseActionNew.CaseMemberID;
                WorkerToDo workerToDo = new WorkerToDo()
                {
                    LastUpdateDate        = DateTime.Now,
                    LastUpdatedByWorkerID = CaseActionNew.LastUpdatedByWorkerID,
                    ReferenceLink         = caseLink,
                    WorkerID    = CaseActionNew.WorkerID.Value,
                    IsCompleted = false,
                };
                if (isNew)
                {
                    workerToDo.Subject = "A new action has been assigned to you. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the detail.";
                }
                else
                {
                    workerToDo.Subject = "An action assigned to you has been updated. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the detail.";
                }
                workertodoRepository.InsertOrUpdate(workerToDo);
                workertodoRepository.Save();
            }
        }
コード例 #2
0
        /// <summary>
        /// Add or Update caseaction to database
        /// </summary>
        /// <param name="caseaction">data to save</param>
        public void InsertOrUpdate(CaseAction caseaction)
        {
            bool isNew = false;

            if (caseaction.CaseSmartGoalServiceProviderID > 0)
            {
                caseaction.CaseProgressNoteID = null;
                caseaction.CaseSmartGoalID    = null;
            }
            if (caseaction.CaseProgressNoteID == 0)
            {
                caseaction.CaseProgressNoteID = null;
            }
            if (caseaction.CaseSmartGoalID == 0)
            {
                caseaction.CaseSmartGoalID = null;
            }
            caseaction.LastUpdateDate = DateTime.Now;
            if (caseaction.ID == default(int))
            {
                isNew = true;
                //set the date when this record was created
                caseaction.CreateDate = caseaction.LastUpdateDate;
                //set the id of the worker who has created this record
                caseaction.CreatedByWorkerID = caseaction.LastUpdatedByWorkerID;
                //add a new record to database
                context.CaseAction.Add(caseaction);
            }
            else
            {
                //update an existing record to database
                context.Entry(caseaction).State = System.Data.Entity.EntityState.Modified;
            }
            Save();
            if (caseaction.CaseProgressNoteID.HasValue && caseaction.CaseProgressNoteID.Value > 0)
            {
                CaseWorker primaryWorker = caseworkerRepository.FindPrimary(caseaction.CaseID);
                if (primaryWorker != null)
                {
                    string             caseLink           = "/CaseManagement/CaseProgressNote/Edit?noteID=" + caseaction.CaseProgressNoteID.Value + "&CaseID=" + caseaction.CaseID + "&CaseMemberID=" + caseaction.CaseMemberID;
                    WorkerNotification workerNotification = new WorkerNotification()
                    {
                        IsRead                = false,
                        LastUpdateDate        = DateTime.Now,
                        LastUpdatedByWorkerID = caseaction.LastUpdatedByWorkerID,
                        ReferenceLink         = caseLink,
                        WorkerID              = primaryWorker.WorkerID
                    };
                    if (isNew)
                    {
                        workerNotification.Notification = "A new action has been added to a progress note. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the note detail.";
                    }
                    else
                    {
                        workerNotification.Notification = "A progress note action has been updated. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the note detail.";
                    }
                    workernotificationRepository.InsertOrUpdate(workerNotification);
                    workernotificationRepository.Save();
                }
            }
            else if (caseaction.CaseSmartGoalServiceProviderID.HasValue && caseaction.CaseSmartGoalServiceProviderID.Value > 0)
            {
                CaseSmartGoalServiceProvider casesmartgoalserviceprovider = casesmartgoalserviceproviderRepository.Find(caseaction.CaseSmartGoalServiceProviderID.Value);
                if (casesmartgoalserviceprovider != null && casesmartgoalserviceprovider.WorkerID.HasValue && casesmartgoalserviceprovider.WorkerID.Value > 0)
                {
                    string             caseLink           = "/CaseManagement/CaseSmartGoalServiceProvider/Index?casesmartgoalId=" + casesmartgoalserviceprovider.CaseSmartGoalID + "&CaseID=" + caseaction.CaseID + "&CaseMemberID=" + caseaction.CaseMemberID;
                    WorkerNotification workerNotification = new WorkerNotification()
                    {
                        IsRead                = false,
                        LastUpdateDate        = DateTime.Now,
                        LastUpdatedByWorkerID = casesmartgoalserviceprovider.LastUpdatedByWorkerID,
                        ReferenceLink         = caseLink,
                        WorkerID              = casesmartgoalserviceprovider.WorkerID.Value
                    };
                    if (isNew)
                    {
                        workerNotification.Notification = "A new action has been added to a service provider. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the service provider detail.";
                    }
                    else
                    {
                        workerNotification.Notification = "A service provider action has been updated. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the service provider detail.";
                    }
                    workernotificationRepository.InsertOrUpdate(workerNotification);
                    workernotificationRepository.Save();
                }
            }

            if (caseaction.CaseWorkerID.HasValue && caseaction.CaseWorkerID.Value > 0)
            {
                int workerID = 0;
                if (caseaction.CaseSmartGoalServiceProviderID.HasValue && caseaction.CaseSmartGoalServiceProviderID.Value > 0)
                {
                    CaseSmartGoalServiceProvider casesmartgoalserviceprovider = casesmartgoalserviceproviderRepository.Find(caseaction.CaseSmartGoalServiceProviderID.Value);
                    if (casesmartgoalserviceprovider != null && casesmartgoalserviceprovider.WorkerID.HasValue)
                    {
                        workerID = casesmartgoalserviceprovider.WorkerID.Value;
                    }
                }
                if (workerID == 0)
                {
                    CaseWorker caseWorker = caseworkerRepository.Find(caseaction.CaseWorkerID.Value);
                    if (caseWorker != null)
                    {
                        workerID = caseWorker.WorkerID;
                    }
                }
                if (workerID > 0)
                {
                    string     caseLink   = "/CaseManagement/CaseAction/Index?CaseID=" + caseaction.CaseID + "&CaseMemberID=" + caseaction.CaseMemberID;
                    WorkerToDo workerToDo = new WorkerToDo()
                    {
                        LastUpdateDate        = DateTime.Now,
                        LastUpdatedByWorkerID = caseaction.LastUpdatedByWorkerID,
                        ReferenceLink         = caseLink,
                        WorkerID    = workerID,
                        IsCompleted = false,
                    };
                    if (isNew)
                    {
                        workerToDo.Subject = "A new action has been assigned to you. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the detail.";
                    }
                    else if (caseaction.IsCompleted)
                    {
                        workerToDo.Subject = "An action assigned to you has been completed. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the detail.";
                    }
                    else
                    {
                        workerToDo.Subject = "An action assigned to you has been updated. Please <a href='" + caseLink + "' target='_blank'>click here</a> to see the detail.";
                    }
                    workertodoRepository.InsertOrUpdate(workerToDo);
                    workertodoRepository.Save();
                }
            }
        }