示例#1
0
        public async Task <bool> markPhysicalDischarge(string caseGuid)
        {
            try
            {
                SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

                xrm.Incident entity = (xrm.Incident)entityRepository.GetEntity(xrm.Incident.EntityLogicalName, new Guid(caseGuid), new Microsoft.Xrm.Sdk.Query.ColumnSet(true));

                if (entity != null)
                {
                    if (entity.Attributes.Contains("mzk_casestatus"))
                    {
                        mzk_casestatus caseStatus = (mzk_casestatus)((OptionSetValue)entity.Attributes["mzk_casestatus"]).Value;

                        if (caseStatus != mzk_casestatus.FinanciallyDischarged)
                        {
                            throw new ValidationException("Only Financially discharged cases can be Physically discharged");
                        }

                        entity.mzk_casestatus = new OptionSetValue((int)mzk_casestatus.PhysicallyDischarged);

                        entityRepository.UpdateEntity(entity);

                        this.createStatusLog((int)mzk_casestatus.PhysicallyDischarged, caseGuid);

                        if (AppSettings.GetByKey("OperationsIntegration").ToLower() == true.ToString().ToLower())
                        {
                            CaseRepository caseRepo = new CaseRepository();

                            caseRepo.updateCaseStatus(caseGuid, HMCaseStatus.PhysicalDischarge);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(true);
        }