public int UpdateWellClassification2(WellClassification wellClassification)
        {
            try
            {
                if (wellClassification == null || wellClassification.WellClassificationId < 1)
                {
                    return(-2);
                }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    var entityToUpdate = db.WellClassifications.ToList().Find(m => m.WellClassificationId == wellClassification.WellClassificationId);
                    if (entityToUpdate == null || entityToUpdate.WellClassificationId < 1)
                    {
                        return(-2);
                    }

                    entityToUpdate.WellClassId     = wellClassification.WellClassId;
                    entityToUpdate.WellId          = wellClassification.WellId;
                    db.Entry(entityToUpdate).State = EntityState.Modified;
                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Beispiel #2
0
 public int UpdateBlockCheckDuplicate(Block block)
 {
     try
     {
         if (block == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             if (db.Blocks.Any())
             {
                 if (db.Blocks.Count(m => m.Name.ToLower().Replace(" ", string.Empty) == block.Name.ToLower().Replace(" ", string.Empty) && m.BlockId != block.BlockId) > 0)
                 {
                     return(-3);
                 }
             }
             db.Blocks.Attach(block);
             db.Entry(block).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Beispiel #3
0
        public int UpdateMilestoneStatusCheckDuplicate(MilestoneStatu milestoneStatus)
        {
            try
            {
                if (milestoneStatus == null)
                { return -2; }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    if (db.MilestoneStatus.Any())
                    {
                        if (db.MilestoneStatus.Count(m => m.Name.ToLower().Replace(" ", string.Empty) == milestoneStatus.Name.ToLower().Replace(" ", string.Empty) && m.MilestoneStatusId != milestoneStatus.MilestoneStatusId) > 0)
                        {
                            return -3;
                        }
                    }

                    db.MilestoneStatus.Attach(milestoneStatus);
                    db.Entry(milestoneStatus).State = EntityState.Modified;
                    return db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return 0;
            }
        }
        public int UpdateWellTypeCheckDuplicate(WellType wellType)
        {
            try
            {
                if (wellType == null)
                {
                    return(-2);
                }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    if (db.WellTypes.Any())
                    {
                        if (db.WellTypes.Count(m => m.Title.ToLower().Replace(" ", string.Empty) == wellType.Title.ToLower().Replace(" ", string.Empty) && m.WellTypeId != wellType.WellTypeId) > 0)
                        {
                            return(-3);
                        }
                    }

                    db.WellTypes.Attach(wellType);
                    db.Entry(wellType).State = EntityState.Modified;
                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
Beispiel #5
0
        public int UpdateProductCheckDuplicate(Product product)
        {
            try
            {
                if (product == null)
                {
                    return(-2);
                }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    if (db.Products.Any())
                    {
                        if (db.Products.Count(m => m.Name.ToLower().Replace(" ", string.Empty) == product.Name.ToLower().Replace(" ", string.Empty) && m.ProductId != product.ProductId) > 0)
                        {
                            return(-3);
                        }
                    }

                    db.Products.Attach(product);
                    db.Entry(product).State = EntityState.Modified;
                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
        public int UpdateCompanyCheckDuplicate(Company company, Person person)
        {
            try
            {
                if (company == null)
                {
                    return(-2);
                }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    if (db.Companies.Any())
                    {
                        if (db.Companies.Count(m => m.Name.ToLower().Replace(" ", string.Empty) == company.Name.ToLower().Replace(" ", string.Empty) && m.CompanyId != company.CompanyId) > 0)
                        {
                            return(-3);
                        }
                    }

                    db.Companies.Attach(company);
                    db.Entry(company).State = EntityState.Modified;
                    db.SaveChanges();
                    var status = 0;

                    if (person != null)
                    {
                        if (person.PersonId < 1)
                        {
                            person.CompanyId = company.CompanyId;
                            var processStatus = new PersonServices().AddPersonCheckDuplicate(person);
                            if (processStatus < 1)
                            {
                                return(status);
                            }
                            status = 1;
                        }
                        else
                        {
                            var processStatus = new PersonServices().UpdatePersonCheckDuplicate(person);
                            if (processStatus < 1)
                            {
                                return(status);
                            }
                            status = 1;
                        }
                    }

                    return(status);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
        public int UpdateWellCheckDuplicate(Well well)
        {
            try
            {
                if (well == null)
                {
                    return(-2);
                }
                using (var db = new DPRDataMigrationEngineDBEntities())
                {
                    if (db.Wells.Any())
                    {
                        if (db.Wells.Count(m => m.Name.ToLower().Replace(" ", string.Empty) == well.Name.ToLower().Replace(" ", string.Empty) && m.WellId != well.WellId && m.FieldId == well.FieldId) > 0)
                        {
                            return(-3);
                        }
                    }

                    var newWellClassification = new WellClassification
                    {
                        WellClassId          = well.WellClassId,
                        WellId               = well.WellId,
                        WellClassificationId = well.WellClassificationId
                    };

                    var classidicationUpdate = new WellClassificationServices().UpdateWellClassification2(newWellClassification);

                    if (classidicationUpdate < 1)
                    {
                        return(-2);
                    }

                    db.Wells.Attach(well);
                    db.Entry(well).State = EntityState.Modified;
                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
 public int UpdateWellWorkover(WellWorkover wellWorkover)
 {
     try
     {
         if (wellWorkover == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             db.WellWorkovers.Attach(wellWorkover);
             db.Entry(wellWorkover).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public int UpdateProjectMileStoneCheckDuplicate(ProjectMileStone projectMileStone)
 {
     try
     {
         if (projectMileStone == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             db.ProjectMileStones.Attach(projectMileStone);
             db.Entry(projectMileStone).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
Beispiel #10
0
 public int UpdateIncidentHistory(IncidentHistory incidentHistory)
 {
     try
     {
         if (incidentHistory == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             db.IncidentHistories.Attach(incidentHistory);
             db.Entry(incidentHistory).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public int UpdateSys_Params(Sys_Param sys_Param)
 {
     try
     {
         if (sys_Param == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             db.Sys_Param.Attach(sys_Param);
             db.Entry(sys_Param).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }
 public int UpdateWellClassification(WellClassification wellClassification)
 {
     try
     {
         if (wellClassification == null)
         {
             return(-2);
         }
         using (var db = new DPRDataMigrationEngineDBEntities())
         {
             var txx = db.WellClassifications.Attach(wellClassification);
             db.Entry(wellClassification).State = EntityState.Modified;
             db.SaveChanges();
             return(txx.WellClassificationId);
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
         return(0);
     }
 }