Ejemplo n.º 1
0
 public void Update(RiskAssessmentHazardMeasure entity, int LoggedInUserId, int LoggedInOrganizationId)
 {
     base.Update(entity);
     _unitOfWork.Save();
 }
Ejemplo n.º 2
0
        public int ReviewRiskAssessment(int id, int Userid, int OrganizationId)
        {
            var data = GetSingle(id, Userid, OrganizationId);

            data.IsArchived = true;
            Update(data);

            // Adding changes to generate new riskassessment
            RiskAssessment riskAssessment = new RiskAssessment();

            riskAssessment.IsArchived         = false;
            riskAssessment.Status             = 0;
            riskAssessment.Area               = data.Area;
            riskAssessment.AssessmentDate     = DateTime.Now;
            riskAssessment.ReviewDuration     = data.ReviewDuration;
            riskAssessment.ReviewDurationUnit = data.ReviewDurationUnit;
            riskAssessment.TrainingRequired   = data.TrainingRequired;
            riskAssessment.IsDeleted          = false;
            riskAssessment.OrganizationId     = OrganizationId;
            base.Insert(riskAssessment);
            this._unitOfWork.Save();

            var riskAssessmentTeamList = this._IRiskAssessmentTeamRepository.GetAllWithRiskAssessmentId(id, Userid, OrganizationId);

            if (riskAssessmentTeamList != null && riskAssessmentTeamList.Any())
            {
                foreach (var riskTeam in riskAssessmentTeamList)
                {
                    RiskAssessmentTeam riskAssessmentTeam = new RiskAssessmentTeam();
                    riskAssessmentTeam.RiskAssessmentId = riskAssessment.RiskAssessmentId;
                    riskAssessmentTeam.UserId           = riskTeam.UserId;
                    riskAssessmentTeam.SignedDate       = riskTeam.SignedDate;
                    riskAssessmentTeam.OrganizationId   = OrganizationId;
                    this._IRiskAssessmentTeamRepository.Add(riskAssessmentTeam, Userid, OrganizationId);
                }
            }

            var riskAssessmentHazardList = this._IRiskAssessmentHazardRepository.GetAllWithRiskAssessmentId(id, Userid, OrganizationId);

            if (riskAssessmentHazardList != null && riskAssessmentHazardList.Any())
            {
                foreach (var riskAssessmentHazard in riskAssessmentHazardList)
                {
                    RiskAssessmentHazard hazard = new RiskAssessmentHazard();
                    hazard.RiskAssessmentId = riskAssessment.RiskAssessmentId;
                    hazard.HazardId         = riskAssessmentHazard.HazardId;
                    hazard.Description      = riskAssessmentHazard.Description;
                    hazard.OrganizationId   = OrganizationId;
                    this._IRiskAssessmentHazardRepository.Add(hazard, Userid, OrganizationId);

                    var riskAssessmentHazardReview    = this._IRiskAssessmentHazardReviewRepository.GetSingleWithHazardId(riskAssessmentHazard.RiskAssessmentHarardId, Userid, OrganizationId);
                    RiskAssessmentHazardReview review = new RiskAssessmentHazardReview();
                    if (riskAssessmentHazardReview != null)
                    {
                        review.RiskAssessmentHazardId = hazard.RiskAssessmentHarardId;
                        review.CreatedDate            = DateTime.Now;
                        review.UpdatedDate            = DateTime.Now;
                        review.Consequence            = riskAssessmentHazardReview.First().Consequence;
                        review.Likelihood             = riskAssessmentHazardReview.First().Likelihood;
                        review.MonitoringMethodId     = riskAssessmentHazardReview.First().MonitoringMethodId;
                        this._IRiskAssessmentHazardReviewRepository.Add(review, Userid, OrganizationId);
                    }

                    var riskAssessmentHazardMeasure = this._IRiskAssessmentHazardMeasureRepository.GetSingleWithHazardId(riskAssessmentHazard.RiskAssessmentHarardId, Userid, OrganizationId);
                    if (riskAssessmentHazardMeasure != null && riskAssessmentHazardMeasure.Any())
                    {
                        foreach (var measure in riskAssessmentHazardMeasure)
                        {
                            RiskAssessmentHazardMeasure riskMeasure = new RiskAssessmentHazardMeasure();
                            riskMeasure.RiskAssessmentId       = riskAssessment.RiskAssessmentId;
                            riskMeasure.RiskAssessmentHazardId = hazard.RiskAssessmentHarardId;
                            riskMeasure.Text      = measure.Text;
                            riskMeasure.DateAdded = DateTime.Now;
                            riskMeasure.RiskAssessmentHazardReviewId = review.RiskAssessmentHazardReviewId;
                            riskMeasure.ActionId       = measure.ActionId;
                            riskMeasure.OrganizationId = OrganizationId;
                            this._IRiskAssessmentHazardMeasureRepository.Add(riskMeasure, Userid, OrganizationId);
                        }
                    }
                }
            }
            this._unitOfWork.Save();
            // changes ends here

            return(riskAssessment.RiskAssessmentId);
        }
Ejemplo n.º 3
0
        public int AddUpdateRiskAssessment(RiskAssessmentViewModel model, int Userid, int OrganizationId)
        {
            RiskAssessment riskAssessment = Mapper.Map <RiskAssessmentViewModel, RiskAssessment>(model);

            if (model.RiskAssessmentId == 0)
            {
                riskAssessment.Status         = 0;
                riskAssessment.IsArchived     = false;
                riskAssessment.OrganizationId = OrganizationId;
                base.Insert(riskAssessment);
                this._unitOfWork.Save();
            }
            else
            {
                riskAssessment                    = GetSingle(model.RiskAssessmentId, Userid, OrganizationId);
                riskAssessment.Area               = model.Area;
                riskAssessment.AssessmentDate     = model.AssessmentDate;
                riskAssessment.ReviewDuration     = model.ReviewDuration;
                riskAssessment.ReviewDurationUnit = model.ReviewDurationUnit;
                riskAssessment.ReviewDate         = DateTime.Now;
                riskAssessment.TrainingRequired   = model.TrainingRequired;
                base.Update(riskAssessment);
            }
            base.RepositoryContext.SP_DeleteAllRiskAssessmentTeam(riskAssessment.RiskAssessmentId, OrganizationId);
            if (model.RiskAssessmentTeamViewModel != null && model.RiskAssessmentTeamViewModel.Any())
            {
                foreach (RiskAssessmentTeamViewModel viewModel in model.RiskAssessmentTeamViewModel)
                {
                    RiskAssessmentTeam riskAssessmentTeam = Mapper.Map <RiskAssessmentTeamViewModel, RiskAssessmentTeam>(viewModel);
                    riskAssessmentTeam.RiskAssessmentId = riskAssessment.RiskAssessmentId;
                    riskAssessmentTeam.OrganizationId   = OrganizationId;
                    this._IRiskAssessmentTeamRepository.Add(riskAssessmentTeam, Userid, OrganizationId);
                }
            }
            if (model.RiskAssessmentHazardViewModel != null && model.RiskAssessmentHazardViewModel.Any())
            {
                foreach (RiskAssessmentHazardViewModel viewModel in model.RiskAssessmentHazardViewModel)
                {
                    RiskAssessmentHazard riskAssessmentHazard = Mapper.Map <RiskAssessmentHazardViewModel, RiskAssessmentHazard>(viewModel);
                    riskAssessmentHazard.OrganizationId = OrganizationId;
                    this._IRiskAssessmentHazardRepository.Add(riskAssessmentHazard, Userid, OrganizationId);
                    if (viewModel.RiskAssessmentHazardMeasureViewModel != null && viewModel.RiskAssessmentHazardMeasureViewModel.Any())
                    {
                        foreach (RiskAssessmentHazardMeasureViewModel viewModel1 in viewModel.RiskAssessmentHazardMeasureViewModel)
                        {
                            RiskAssessmentHazardMeasure riskAssessmentHazardMeasure = Mapper.Map <RiskAssessmentHazardMeasureViewModel, RiskAssessmentHazardMeasure>(viewModel1);
                            riskAssessmentHazardMeasure.OrganizationId = OrganizationId;
                            this._IRiskAssessmentHazardMeasureRepository.Add(riskAssessmentHazardMeasure, Userid, OrganizationId);
                        }
                    }
                    if (viewModel.RiskAssessmentHazardReviewViewModel != null && viewModel.RiskAssessmentHazardReviewViewModel.Any())
                    {
                        foreach (RiskAssessmentHazardReviewViewModel viewModel2 in viewModel.RiskAssessmentHazardReviewViewModel)
                        {
                            RiskAssessmentHazardReview riskAssessmentHazardReview = Mapper.Map <RiskAssessmentHazardReviewViewModel, RiskAssessmentHazardReview>(viewModel2);
                            riskAssessmentHazardReview.CreatedDate    = DateTime.Now;
                            riskAssessmentHazardReview.UpdatedDate    = DateTime.Now;
                            riskAssessmentHazardReview.OrganizationId = OrganizationId;
                            this._IRiskAssessmentHazardReviewRepository.Add(riskAssessmentHazardReview, Userid, OrganizationId);
                        }
                    }
                }
            }
            this._unitOfWork.Save();
            return(riskAssessment.RiskAssessmentId);
        }
Ejemplo n.º 4
0
        public int AddUpdateRiskAssessmentHazard(RiskAssessmentHazardViewModel model, int Userid, int OrganizationId)
        {
            //if (model.IsReadyForReview)
            //{
            //    base.RepositoryContext.SP_SerRiskAssessmentReviewDate(model.RiskAssessmentHarardId);
            //}
            base.RepositoryContext.sp_DeleteHazardReviewAndMeasure(model.RiskAssessmentHarardId, OrganizationId);
            RiskAssessmentHazard riskAssessmentHazard = Mapper.Map <RiskAssessmentHazardViewModel, RiskAssessmentHazard>(model);

            if (model.RiskAssessmentHarardId == 0)
            {
                riskAssessmentHazard.OrganizationId = OrganizationId;
                this._IRiskAssessmentHazardRepository.Add(riskAssessmentHazard, Userid, OrganizationId);
            }
            else
            {
                var data = this._IRiskAssessmentHazardRepository.GetSingle(model.RiskAssessmentHarardId, Userid, OrganizationId);
                data.Description = model.Description;
                this._IRiskAssessmentHazardRepository.Update(data, Userid, OrganizationId);
            }
            RiskAssessmentHazardReview riskAssessmentHazardReview = new RiskAssessmentHazardReview();

            if (model.RiskAssessmentHazardReviewViewModel != null && model.RiskAssessmentHazardReviewViewModel.Any())
            {
                foreach (RiskAssessmentHazardReviewViewModel viewModel2 in model.RiskAssessmentHazardReviewViewModel)
                {
                    riskAssessmentHazardReview                        = Mapper.Map <RiskAssessmentHazardReviewViewModel, RiskAssessmentHazardReview>(viewModel2);
                    riskAssessmentHazardReview.CreatedDate            = DateTime.Now;
                    riskAssessmentHazardReview.UpdatedDate            = DateTime.Now;
                    riskAssessmentHazardReview.RiskAssessmentHazardId = riskAssessmentHazard.RiskAssessmentHarardId;
                    riskAssessmentHazardReview.OrganizationId         = OrganizationId;
                    this._IRiskAssessmentHazardReviewRepository.Add(riskAssessmentHazardReview, Userid, OrganizationId);
                }
            }
            if (model.RiskAssessmentHazardMeasureViewModel != null && model.RiskAssessmentHazardMeasureViewModel.Any())
            {
                foreach (RiskAssessmentHazardMeasureViewModel viewModel1 in model.RiskAssessmentHazardMeasureViewModel)
                {
                    RiskAssessmentHazardMeasure riskAssessmentHazardMeasure = Mapper.Map <RiskAssessmentHazardMeasureViewModel, RiskAssessmentHazardMeasure>(viewModel1);
                    riskAssessmentHazardMeasure.RiskAssessmentHazardId = riskAssessmentHazard.RiskAssessmentHarardId;
                    riskAssessmentHazardMeasure.RiskAssessmentId       = riskAssessmentHazard.RiskAssessmentId;
                    riskAssessmentHazardMeasure.DateAdded = DateTime.Now;
                    riskAssessmentHazardMeasure.RiskAssessmentHazardReviewId = riskAssessmentHazardReview.RiskAssessmentHazardReviewId;
                    riskAssessmentHazardMeasure.OrganizationId = OrganizationId;
                    this._IRiskAssessmentHazardMeasureRepository.Add(riskAssessmentHazardMeasure, Userid, OrganizationId);
                    if (viewModel1.ActionId == 1)
                    {
                        Angular2_AspDotNet.Data.Action action = new Angular2_AspDotNet.Data.Action();
                        action.SourceID         = riskAssessmentHazardMeasure.RiskAssessmentHazardMeasureId;
                        action.Title            = riskAssessmentHazardMeasure.Text;
                        action.Duedate          = DateTime.Now.AddDays(7);
                        action.ActionSourceID   = 4;
                        action.IsActionRequired = true;
                        action.CategoryID       = 7;
                        action.OrganizationID   = OrganizationId;
                        this._IActionRepository.Add(action, Userid, OrganizationId);
                    }
                }
            }
            //RiskAssessment riskAssessment = GetSingle(Convert.ToInt32(riskAssessmentHazard.RiskAssessmentId));
            //riskAssessment.ReviewDate = DateTime.Now;
            //Update(riskAssessment);
            this._unitOfWork.Save();
            return(riskAssessmentHazard.RiskAssessmentHarardId);
        }