Esempio n. 1
0
        public Plant Add(Plant plant)
        {
            Plants plantDb = _mapper.Map <Plant, Plants>(plant);

            _ctx.Plants.Add(plantDb);
            _ctx.SaveChanges();
            return(_mapper.Map <Plants, Plant>(plantDb));
        }
Esempio n. 2
0
        public Sector Add(Sector sector)
        {
            Sectors sectorDb = _mapper.Map <Sector, Sectors>(sector);

            _ctx.Sectors.Add(sectorDb);
            _ctx.SaveChanges();
            return(_mapper.Map <Sectors, Sector>(sectorDb));
        }
Esempio n. 3
0
        public Company Add(Company company)
        {
            Companies companyDb = _mapper.Map <Company, Companies>(company);

            _ctx.Companies.Add(companyDb);
            _ctx.SaveChanges();

            return(_mapper.Map <Companies, Company>(companyDb));
        }
Esempio n. 4
0
        public AuditType Add(AuditType auditType)
        {
            AuditsTypes typeDB = _mapper.Map <AuditType, AuditsTypes>(auditType);

            _ctx.AuditsTypes.Add(typeDB);
            _ctx.SaveChanges();

            return(_mapper.Map <AuditsTypes, AuditType>(typeDB));
        }
Esempio n. 5
0
        public Job Add(Job job)
        {
            Jobs jobDb = _mapper.Map <Job, Jobs>(job);

            _ctx.Jobs.Add(jobDb);
            _ctx.SaveChanges();

            return(_mapper.Map <Jobs, Job>(jobDb));
        }
        public FindingType Add(FindingType findingType)
        {
            var findingTypeDb = _mapper.Map <FindingType, FindingTypes>(findingType);

            findingTypeDb.ParametrizationsFindingTypes = _mapper.Map <List <FindingTypeParametrization>, ICollection <ParametrizationsFindingTypes> >(findingType.Parametrizations);
            _ctx.Add(findingTypeDb);
            _ctx.SaveChanges();

            findingType.Id = findingTypeDb.FindingTypeID;

            return(findingType);
        }
        public bool InsertOrUpdate(Dictionary <string, List <AlertUser> > dicAlertUser)
        {
            foreach (string alertType in dicAlertUser.Keys)
            {
                List <Domain.AlertUser.AlertUser> listAlertUser = dicAlertUser[alertType];
                foreach (Domain.AlertUser.AlertUser alertUser in listAlertUser)
                {
                    Entities.AlertUsers alertUserNewOrUpdate = null;

                    if (alertUser.AlertUsersID <= 0)
                    {
                        alertUserNewOrUpdate               = new Entities.AlertUsers();
                        alertUserNewOrUpdate.AlertID       = alertUser.AlertID;
                        alertUserNewOrUpdate.GenerateAlert = alertUser.GenerateAlert;
                        alertUserNewOrUpdate.UsersID       = alertUser.UsersID;
                        _ctx.AlertUsers.Add(alertUserNewOrUpdate);
                    }
                    else
                    {
                        alertUserNewOrUpdate = _ctx.AlertUsers.Where(x => x.AlertUsersID == alertUser.AlertUsersID).SingleOrDefault();
                        alertUserNewOrUpdate.GenerateAlert = alertUser.GenerateAlert;
                        _ctx.AlertUsers.Update(alertUserNewOrUpdate);
                    }
                }
            }

            _ctx.SaveChanges();
            return(true);
        }
        public ParametrizationCriteria Add(ParametrizationCriteria newparam)
        {
            var param = _ctx.ParametrizationCriterias.Where(x => x.Name == newparam.Name).FirstOrDefault();

            if (param == null)
            {
                var paramCriteria = new ParametrizationCriterias();
                paramCriteria.Name     = newparam.Name;
                paramCriteria.DataType = newparam.DataType;

                _ctx.ParametrizationCriterias.Add(paramCriteria);
                _ctx.SaveChanges();

                newparam.Id = paramCriteria.ParametrizationCriteriaID;
                return(newparam);
            }
            return(null);
        }
Esempio n. 9
0
 public int DeleteAllByCorrectionAction(int correctiveActionId)
 {
     try
     {
         var fishboneCausesToRemove = _ctx.CorrectiveActionFishbone.Where(x => x.CorrectiveActionID == correctiveActionId).ToList();
         _ctx.CorrectiveActionFishbone.RemoveRange(fishboneCausesToRemove);
         _ctx.SaveChanges();
         return(fishboneCausesToRemove.Count);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 10
0
        public GetUpdatedJobsOfSectorTest()
        {
            var optionsBuilder = new DbContextOptionsBuilder <SQLHoshinCoreContext>()
                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                 .Options;

            _ctx = new SQLHoshinCoreContext(optionsBuilder);

            jobs          = new List <Domain.Job.Job>();
            sectorsPlants = new SectorsPlants();
            jobsDbSet     = new List <Jobs>
            {
                new Jobs {
                    JobID = 1
                },
                new Jobs {
                    JobID = 2
                },
                new Jobs {
                    JobID = 3
                },
                new Jobs {
                    JobID = 4
                },
                new Jobs {
                    JobID = 5
                },
                new Jobs {
                    JobID = 6
                },
                new Jobs {
                    JobID = 7
                },
                new Jobs {
                    JobID = 8
                },
                new Jobs {
                    JobID = 9
                },
                new Jobs {
                    JobID = 10
                }
            };

            _ctx.Jobs.AddRange(jobsDbSet);
            _ctx.SaveChanges();

            sectorsPlants.JobsSectorsPlants = new List <JobsSectorsPlants>();
            sectorsPlants.JobsSectorsPlants.Add(new JobsSectorsPlants
            {
                PlantID  = 1,
                SectorID = 1,
                JobID    = 1,
            });

            sectorsPlants.JobsSectorsPlants.Add(new JobsSectorsPlants
            {
                PlantID  = 1,
                SectorID = 1,
                JobID    = 2,
            });

            sectorsPlants.JobsSectorsPlants.Add(new JobsSectorsPlants
            {
                PlantID  = 1,
                SectorID = 1,
                JobID    = 3,
            });

            sectorsPlants.JobsSectorsPlants.Add(new JobsSectorsPlants
            {
                PlantID  = 1,
                SectorID = 1,
                JobID    = 4,
            });
        }