public CompanyPartner GetCompanyPartnerByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var CompanyPartner = context.CompanyPartner.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (CompanyPartner == null)
                    {
                        CompanyPartner = new CompanyPartner()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.CompanyPartner.Add(CompanyPartner);
                        context.SaveChanges();
                        return(CompanyPartner);
                    }

                    return(CompanyPartner);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        public OdometreStatus GetOdometreStatusByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var OdometreStatus = context.OdometreStatus.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (OdometreStatus == null)
                    {
                        OdometreStatus = new OdometreStatus()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.OdometreStatus.Add(OdometreStatus);
                        context.SaveChanges();
                        return(OdometreStatus);
                    }

                    return(OdometreStatus);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 3
0
        public Sector GetSectorByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var Sector = context.Sector.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (Sector == null)
                    {
                        Sector = new Sector()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.Sector.Add(Sector);
                        context.SaveChanges();
                        return(Sector);
                    }

                    return(Sector);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 4
0
        public WocheckerFlag GetWocheckerFlagByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var WocheckerFlag = context.WocheckerFlag.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (WocheckerFlag == null)
                    {
                        WocheckerFlag = new WocheckerFlag()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.WocheckerFlag.Add(WocheckerFlag);
                        context.SaveChanges();
                        return(WocheckerFlag);
                    }

                    return(WocheckerFlag);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 5
0
        public DeviceMontageType GetDeviceMontageTypeByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var DeviceMontageType = context.DeviceMontageType.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (DeviceMontageType == null)
                    {
                        DeviceMontageType = new DeviceMontageType()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.DeviceMontageType.Add(DeviceMontageType);
                        context.SaveChanges();
                        return(DeviceMontageType);
                    }

                    return(DeviceMontageType);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 6
0
        public TerminalProtocol GetTerminalProtocolByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var TerminalProtocol = context.TerminalProtocol.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (TerminalProtocol == null)
                    {
                        TerminalProtocol = new TerminalProtocol()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.TerminalProtocol.Add(TerminalProtocol);
                        context.SaveChanges();
                        return(TerminalProtocol);
                    }

                    return(TerminalProtocol);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 7
0
        public Gateway GetGatewayByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var Gateway = context.Gateway.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (Gateway == null)
                    {
                        Gateway = new Gateway()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.Gateway.Add(Gateway);
                        context.SaveChanges();
                        return(Gateway);
                    }

                    return(Gateway);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 8
0
        public Platform GetPlatformByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var Platform = context.Platform.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (Platform == null && _name != null)
                    {
                        Platform = new Platform()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.Platform.Add(Platform);
                        context.SaveChanges();
                        return(Platform);
                    }
                    return(Platform);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
        public RefTelemetryType GetRefTelemetryTypeByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var RefTelemetryType = context.RefTelemetryType.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (RefTelemetryType == null)
                    {
                        RefTelemetryType = new RefTelemetryType()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.RefTelemetryType.Add(RefTelemetryType);
                        context.SaveChanges();
                        return(RefTelemetryType);
                    }

                    return(RefTelemetryType);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 10
0
        public Messaging GetMessagingByNameOrInsert(string _name)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var Messaging = context.Messaging.FirstOrDefault(x => x.Name.Trim() == _name.Trim() && x.Status > 0);

                    if (Messaging == null)
                    {
                        Messaging = new Messaging()
                        {
                            Name   = _name.Trim(),
                            Status = 1
                        };

                        context.Messaging.Add(Messaging);
                        context.SaveChanges();
                        return(Messaging);
                    }

                    return(Messaging);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
Ejemplo n.º 11
0
        public SoftwareVersion GetSoftwareVersionByNameOrInsert(string _name, int _terminalTypeId)
        {
            try
            {
                using (var context = new VeraEntities())
                {
                    var SoftwareVersion = context.SoftwareVersion.FirstOrDefault(x => x.VersionCode.Trim() == _name.Trim() && x.Status > 0 && x.TerminalTypeId == _terminalTypeId);

                    if (SoftwareVersion == null)
                    {
                        SoftwareVersion = new SoftwareVersion()
                        {
                            VersionCode    = _name.Trim(),
                            Status         = 1,
                            TerminalTypeId = _terminalTypeId
                        };

                        context.SoftwareVersion.Add(SoftwareVersion);
                        context.SaveChanges();
                        return(SoftwareVersion);
                    }

                    return(SoftwareVersion);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
 public GeographicalAuthority AddNewGeographicalAuthority(GeographicalAuthority _GeographicalAuthority)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.GeographicalAuthority.Add(_GeographicalAuthority);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _GeographicalAuthority : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 13
0
 public Gateway AddNewGateway(Gateway _Gateway)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Gateway.Add(_Gateway);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Gateway : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 14
0
 public Admin AddNewAdmin(Admin _admin)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Admin.Add(_admin);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _admin : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public UserQuestionAnswer AddNewUserQuestionAnswer(UserQuestionAnswer _UserQuestionAnswer)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.UserQuestionAnswer.Add(_UserQuestionAnswer);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _UserQuestionAnswer : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 16
0
 public Platform AddNewPlatform(Platform _Platform)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Platform.Add(_Platform);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Platform : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 17
0
 public Distributor AddNewDistributor(Distributor _distributor)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Distributor.Add(_distributor);
             var numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _distributor : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 18
0
 public SoftwareVersion AddNewSoftwareVersion(SoftwareVersion _SoftwareVersion)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.SoftwareVersion.Add(_SoftwareVersion);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _SoftwareVersion : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 19
0
 public Vehicle AddNewVehicle(Vehicle _Vehicle)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Vehicle.Add(_Vehicle);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Vehicle : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 20
0
 public DeviceData AddNewDeviceData(DeviceData _DeviceData)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.DeviceData.Add(_DeviceData);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _DeviceData : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 21
0
 public Question AddNewQuestion(Question _Question)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Question.Add(_Question);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Question : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 22
0
 public Group AddNewGroup(Group _Group)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Group.Add(_Group);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Group : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 23
0
 public Messaging AddNewMessaging(Messaging _Messaging)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Messaging.Add(_Messaging);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Messaging : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 24
0
 public TerminalProtocol AddNewTerminalProtocol(TerminalProtocol _TerminalProtocol)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.TerminalProtocol.Add(_TerminalProtocol);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _TerminalProtocol : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 25
0
 public CompanyShift AddNewCompanyShift(CompanyShift _CompanyShift)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.CompanyShift.Add(_CompanyShift);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _CompanyShift : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 26
0
 public WocheckerFlag AddNewWocheckerFlag(WocheckerFlag _WocheckerFlag)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.WocheckerFlag.Add(_WocheckerFlag);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _WocheckerFlag : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 27
0
 public UserType AddNewUserType(UserType _UserType)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.UserType.Add(_UserType);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _UserType : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public OdometreStatus AddNewOdometreStatus(OdometreStatus _OdometreStatus)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.OdometreStatus.Add(_OdometreStatus);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _OdometreStatus : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
 public RefTelemetryType AddNewRefTelemetryType(RefTelemetryType _RefTelemetryType)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.RefTelemetryType.Add(_RefTelemetryType);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _RefTelemetryType : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 30
0
 public Area AddNewArea(Area _Area)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             context.Area.Add(_Area);
             int numOfInserted = context.SaveChanges();
             return(numOfInserted > 0 ? _Area : null);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }