コード例 #1
0
        public void Update(int id, Format_Update parseData, int companyId)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                //ExternalDashboard existingData = dbEntity.ExternalDashboard.Find(id);
                ExternalDashboard existingData = (from c in dbEntity.ExternalDashboard
                                                  where c.Id == id && c.CompanyId == companyId
                                                  select c).SingleOrDefault <ExternalDashboard>();
                if (existingData == null)
                {
                    throw new CDSException(10502);
                }

                if (parseData.Name != null)
                {
                    existingData.Name = parseData.Name;
                }

                if (parseData.Ordering > 0)
                {
                    existingData.Ordering = parseData.Ordering;
                }

                if (parseData.URL != null)
                {
                    existingData.URL = parseData.URL;
                }

                dbEntity.Entry(existingData).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #2
0
        public void DeleteById(int id)
        {
            CDStudioEntities dbEntity = new CDStudioEntities();
            var existingDataModel     = dbEntity.APIServiceRefreshToken.Find(id);

            dbEntity.Entry(existingDataModel).State = EntityState.Deleted;
            dbEntity.SaveChanges();
        }
コード例 #3
0
ファイル: UserRoleModel.cs プロジェクト: KevinKao809/CDS20
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                UserRole existingData = dbEntity.UserRole.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(12103);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #4
0
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                DeviceCertificate existingData = dbEntity.DeviceCertificate.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(10401);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #5
0
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                SystemConfiguration existingData = dbEntity.SystemConfiguration.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(11901);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #6
0
ファイル: EquipmentModel.cs プロジェクト: KevinKao809/CDS20
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                Equipment existingData = dbEntity.Equipment.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(10501);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #7
0
        public void Delete(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                Factory existingFactory = dbEntity.Factory.Find(id);
                if (existingFactory == null)
                {
                    throw new CDSException(10601);
                }

                dbEntity.Entry(existingFactory).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #8
0
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                Application existingApplication = dbEntity.Application.Find(id);
                if (existingApplication == null)
                {
                    throw new CDSException(10102);
                }

                dbEntity.Entry(existingApplication).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #9
0
ファイル: CompanyModel.cs プロジェクト: KevinKao809/CDS20
        public void UpdateLogoURL(int id, string logoURL, string iconURL)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                var existingCompany = dbEntity.Company.Find(id);
                if (existingCompany == null || existingCompany.DeletedFlag == true)
                {
                    throw new CDSException(10701);
                }

                existingCompany.LogoURL = logoURL;
                existingCompany.IconURL = iconURL;
                dbEntity.Entry(existingCompany).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #10
0
        public void DeleteById(int id, int companyId)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                MetaDataDefination existingData = (from c in dbEntity.MetaDataDefination
                                                   where c.Id == id && c.CompanyId == companyId
                                                   select c).SingleOrDefault <MetaDataDefination>();
                if (existingData == null)
                {
                    throw new CDSException(11301);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #11
0
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                SuperAdmin existingData = dbEntity.SuperAdmin.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(10701);
                }

                existingData.DeletedFlag = true;

                dbEntity.Entry(existingData).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #12
0
        public void DeleteById(int id, int companyId)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                ExternalDashboard existingData = (from c in dbEntity.ExternalDashboard
                                                  where c.Id == id && c.CompanyId == companyId
                                                  select c).SingleOrDefault <ExternalDashboard>();
                if (existingData == null)
                {
                    throw new CDSException(10502);
                }

                dbEntity.Entry(existingData).State = EntityState.Deleted;
                dbEntity.SaveChanges();
            }
        }
コード例 #13
0
ファイル: CompanyModel.cs プロジェクト: KevinKao809/CDS20
        public void DeleteById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                var existingCompany = dbEntity.Company.Find(id);

                if (existingCompany == null)
                {
                    throw new CDSException(10701);
                }

                existingCompany.DeletedFlag           = true;
                dbEntity.Entry(existingCompany).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #14
0
        public void Update(int id, Format_Update parseData)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                DeviceCertificate existingData = dbEntity.DeviceCertificate.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(10401);
                }

                if (parseData.Name != null)
                {
                    existingData.Name = parseData.Name;
                }

                if (parseData.KeyFile != null)
                {
                    existingData.KeyFile = parseData.KeyFile;
                }

                if (parseData.CertFile != null)
                {
                    existingData.CertFile = parseData.CertFile;
                }

                if (parseData.Thumbprint != null)
                {
                    existingData.Thumbprint = parseData.Thumbprint;
                }

                if (parseData.Password != null)
                {
                    existingData.Password = parseData.Password;
                }

                if (parseData.ExpiredAt != null)
                {
                    existingData.ExpiredAt = parseData.ExpiredAt;
                }

                dbEntity.Entry(existingData).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #15
0
        public void Update(int id, Format_Update factory)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                Factory existingFactory = dbEntity.Factory.Find(id);
                if (existingFactory == null)
                {
                    throw new CDSException(10601);
                }

                if (factory.Name != null)
                {
                    existingFactory.Name = factory.Name;
                }

                if (factory.Description != null)
                {
                    existingFactory.Description = factory.Description;
                }

                if (factory.Latitude.HasValue)
                {
                    existingFactory.Latitude = factory.Latitude;
                }

                if (factory.Longitude.HasValue)
                {
                    existingFactory.Longitude = factory.Longitude;
                }

                if (factory.TimeZone.HasValue)
                {
                    existingFactory.TimeZone = Convert.ToInt32(factory.TimeZone);
                }

                if (factory.CultureInfoId != null)
                {
                    existingFactory.CultureInfo = factory.CultureInfoId;
                }

                dbEntity.Entry(existingFactory).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }
コード例 #16
0
        public void Update(int id, Format_Update parseData)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                SystemConfiguration existingData = dbEntity.SystemConfiguration.Find(id);
                if (existingData == null)
                {
                    throw new CDSException(11901);
                }

                if (parseData.Group != null)
                {
                    existingData.Group = parseData.Group;
                }

                if (parseData.Key != null)
                {
                    existingData.Key = parseData.Key;
                }

                if (parseData.Value != null)
                {
                    existingData.Value = parseData.Value;
                }

                dbEntity.Entry(existingData).State = EntityState.Modified;
                try
                {
                    dbEntity.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key"))
                    {
                        throw new CDSException(11902);
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
        }
コード例 #17
0
        public void Update(int id, Format_Update parseData, int companyId)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                //MetaDataDefination existingData = dbEntity.MetaDataDefination.Find(id);
                MetaDataDefination existingData = (from c in dbEntity.MetaDataDefination
                                                   where c.Id == id && c.CompanyId == companyId
                                                   select c).SingleOrDefault <MetaDataDefination>();
                if (existingData == null)
                {
                    throw new CDSException(11301);
                }

                if (parseData.EntityType != null)
                {
                    existingData.EntityType = parseData.EntityType;
                }

                if (parseData.ObjectName != null)
                {
                    existingData.ObjectName = parseData.ObjectName;
                }

                dbEntity.Entry(existingData).State = EntityState.Modified;
                try
                {
                    dbEntity.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    if (ex.InnerException.InnerException.Message.Contains("Cannot insert duplicate key"))
                    {
                        throw new CDSException(11302);
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
        }
コード例 #18
0
        public void Update(int id, Format_Update parseData)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                Application existingApplication = dbEntity.Application.Find(id);
                if (existingApplication == null)
                {
                    throw new CDSException(10102);
                }

                if (parseData.MessageTemplate != null)
                {
                    try
                    {
                        JObject.Parse(parseData.MessageTemplate);
                    }
                    catch
                    {
                        throw new CDSException(10103);
                    }
                    existingApplication.MessageTemplate = parseData.MessageTemplate;
                }

                if (parseData.Name != null)
                {
                    existingApplication.Name = parseData.Name;
                }

                if (parseData.Description != null)
                {
                    existingApplication.Description = parseData.Description;
                }

                if (parseData.TargetType != null)
                {
                    existingApplication.TargetType = parseData.TargetType;
                }

                if (parseData.Method != null)
                {
                    existingApplication.Method = parseData.Method;
                }

                if (parseData.ServiceURL != null)
                {
                    existingApplication.ServiceURL = parseData.ServiceURL;
                }

                if (parseData.AuthType != null)
                {
                    existingApplication.AuthType = parseData.AuthType;
                }

                if (parseData.AuthID != null)
                {
                    existingApplication.AuthID = parseData.AuthID;
                }

                if (parseData.AuthPW != null)
                {
                    existingApplication.AuthPW = parseData.AuthPW;
                }

                if (parseData.TokenURL != null)
                {
                    existingApplication.TokenURL = parseData.TokenURL;
                }

                if (parseData.HeaderValues != null)
                {
                    existingApplication.HeaderValues = parseData.HeaderValues;
                }

                dbEntity.Entry(existingApplication).State = EntityState.Modified;
                dbEntity.SaveChanges();
            }
        }