示例#1
0
        public async Task <Response <Evaluation> > OppositeEvaluationAsync(int userId, int visitId)
        {
            try
            {
                var evaluation = await _repo.GetAnEvaluationWithItsVisitAsync(visitId, userId);

                if (evaluation == null)
                {
                    return(new Response <Evaluation>("evaluation is not found to Modify!"));
                }
                if (!_visitAssertion.AssertActivation(evaluation.Visit))
                {
                    return(new Response <Evaluation>("Visit is not Active Or Deleted !"));
                }
                await _repo.OppositeEvaluationAsync(userId : userId, visitId : visitId);

                await _medicalRepHandlers.HandleEvaluationWithMedicalRepAsync(evaluation, evaluation.Visit, Interacting.Modify);

                await _unitWork.CommitAsync();

                //handle Notification
                var not = await GetEvent(evaluation.Id, (int)NotificationTypesEnum.Evaluation);

                if (!not.Success)
                {
                    return(new Response <Evaluation>("Event is opposited successfully,but Notification is not !"));
                }
                var opposite = new EvaluationOpposite(not.Source);
                opposite.Opposite();
                //end of handling Notification
                await _unitWork.CommitAsync();

                return(new Response <Evaluation>(evaluation));
            }
            catch (Exception e)
            {
                return(new Response <Evaluation>($"Error:Can not Change Evaluation :{e.Message}"));
            }
        }
示例#2
0
        public async Task <Response <VisitReport> > AddReport(VisitReport visitReport)
        {
            try
            {
                var associatedVisit = await _interacting.GetVisitWithItsReportsAsync(visitReport.VisitId);

                if (!associatedVisit.Success)
                {
                    return(new Response <VisitReport>(associatedVisit.Error));
                }

                if (associatedVisit.Source == null)
                {
                    return(new Response <VisitReport>("Visit Is not found!"));
                }

                if (!_assertion.AssertActivation(associatedVisit.Source))
                {
                    return(new Response <VisitReport>("You try to report to deleted or Un Active Comment !"));
                }

                if (associatedVisit.Source.VisitReports.Any(report => report.ReporterId == visitReport.ReporterId))
                {
                    return(new Response <VisitReport>("User already has made a Report to this visit!"));
                }

                if (associatedVisit.Source.Type)
                {
                    return(new Response <VisitReport>("Report Can only applied for the Optional Visits !"));
                }


                associatedVisit.Source.VisitReports.Add(visitReport);

                _visitsHandlers.HandleReportingVisit(associatedVisit.Source, associatedVisit.Source.VisitReports);
                await _reportHandlers.HandleReporting(associatedVisit.Source, associatedVisit.Source.VisitReports);

                await _unitWork.CommitAsync();

                return(new Response <VisitReport>(visitReport));
            }
            catch (Exception e)
            {
                return(new Response <VisitReport>($"Error:{e.Message}"));
            }
        }