Example #1
0
        public CorrectiveAction Add(CorrectiveAction correctiveAction)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                CorrectiveActions newCorrectiveAction = _mapper.Map <CorrectiveAction, CorrectiveActions>(correctiveAction);

                _ctx.CorrectiveActions.Add(newCorrectiveAction);
                _ctx.SaveChanges();

                return(_mapper.Map <CorrectiveActions, CorrectiveAction>(newCorrectiveAction));
            }
        }
Example #2
0
        public CorrectiveActionWorkflowData GetOneByWorkflowId(string workflowId)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                CorrectiveActions correctiveAction = _ctx.CorrectiveActions
                                                     .Include(x => x.CorrectiveActionState)
                                                     .Include(x => x.ResponisbleUser)
                                                     .Include(x => x.ReviewerUser)
                                                     .Include(x => x.SectorPlantTreatment)
                                                     .ThenInclude(x => x.Sector)
                                                     .Where(x => x.WorkflowId == workflowId)
                                                     .FirstOrDefault();

                return(_mapper.Map <CorrectiveActions, CorrectiveActionWorkflowData>(correctiveAction));
            }
        }