Ejemplo n.º 1
0
        public ReassignmentsFindingHistory Add(ReassignmentsFindingHistory newRequestReassign)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                newRequestReassign.Date = DateTime.Today;
                FindingsReassignmentsHistory findingReassignmentsHistory = _mapper.Map <ReassignmentsFindingHistory, FindingsReassignmentsHistory>(newRequestReassign);

                _ctx.FindingsReassignmentsHistories.Add(findingReassignmentsHistory);

                var finding = _ctx.Findings.FirstOrDefault(x => x.FindingID == findingReassignmentsHistory.FindingID);

                FindingsStatesHistory findingsStateHistory = new FindingsStatesHistory();
                findingsStateHistory.FindingID       = finding.FindingID;
                findingsStateHistory.Date            = DateTime.Now;
                findingsStateHistory.FindingStateID  = finding.FindingStateID;
                findingsStateHistory.CreatedByUserID = findingReassignmentsHistory.CreatedByUserID;
                _ctx.FindingsStatesHistories.Add(findingsStateHistory);

                finding.FindingStateID = 16;
                _ctx.Findings.Update(finding);


                _ctx.FindingsReassignmentsHistories.Add(findingReassignmentsHistory);
                _ctx.SaveChanges();

                return(_mapper.Map <FindingsReassignmentsHistory, ReassignmentsFindingHistory>(findingReassignmentsHistory));
            }
        }
        public bool Add(int findingId, int findingStateId, string createdByUserId)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                FindingsStatesHistory f = new FindingsStatesHistory()
                {
                    FindingID       = findingId,
                    FindingStateID  = findingStateId,
                    Date            = DateTime.Now,
                    CreatedByUserID = createdByUserId
                };
                _ctx.FindingsStatesHistories.Add(f);
                _ctx.SaveChanges();

                return(true);
            }
        }