Пример #1
0
        public List <Catagory> GetCategories()
        {
            List <Catagory> objCategories = new List <Catagory>();

            try
            {
                using (Estimator dbContext = new Estimator())
                {
                    objCategories = dbContext.Catogories.ToList();
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join(";", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
            }
            return(objCategories);
        }
Пример #2
0
 public void SaveOutScope(List <OutScope> outScopeItems)
 {
     using (Estimator dbContext = new Estimator())
     {
         dbContext.BulkInsert(outScopeItems);
         dbContext.SaveChanges();
     }
 }
Пример #3
0
 public void SaveAsumptions(List <Assumptions> assumptions)
 {
     using (Estimator dbContext = new Estimator())
     {
         dbContext.BulkInsert(assumptions);
         dbContext.SaveChanges();
     }
 }
Пример #4
0
 public void  SaveEstimateVersionDetails(List <VersionDetails_Phased> estimateVersionDetail)
 {
     using (Estimator dbContext = new Estimator())
     {
         dbContext.BulkInsert(estimateVersionDetail);
         dbContext.SaveChanges();
     }
 }
Пример #5
0
        //[HttpPost]
        public void InsertProjects(IEnumerable <Project> projects)
        {
            try
            {
                using (Estimator dbContext = new Estimator())
                {
                    foreach (Project proj in projects)
                    {
                        if (proj.Id != 0)
                        {
                            var existingProject = dbContext.Projects.Find(proj.Id);

                            DbEntityEntry <Project> ee = dbContext.Entry(existingProject);
                            ee.CurrentValues.SetValues(proj);
                        }
                        else
                        {
                            //dbContext.Projects.AddRange(projects);
                            dbContext.Projects.Add(proj);
                        }
                        dbContext.SaveChanges();
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join(";", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
            }
        }
Пример #6
0
        public List <Project> GetProject(int id)
        {
            List <Project> objProj = new List <Project>();

            try
            {
                using (Estimator dbContext = new Estimator())
                {
                    if (id > 0)
                    {
                        Project proj = dbContext.Projects.Find(id);
                        dbContext.SaveChanges();
                        objProj.Add(proj);
                    }
                    else
                    {
                        dbContext.SaveChanges();
                        objProj.AddRange(dbContext.Projects.ToList());
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join(";", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
            }
            return(objProj);
        }
Пример #7
0
        public int SaveEstimateVersion(EstimationVersionsHistory estimateversion)
        {
            int versionHistoryID = -1;
            EstimationOperations estOperation = new EstimationOperations();

            using (Estimator dbContext = new Estimator())
            {
                if (estimateversion.Id != 0)
                {
                    var existingversionHistory = dbContext.VersionHistory.Find(estimateversion.Id);
                    DbEntityEntry <EstimationVersionsHistory> ee = dbContext.Entry(existingversionHistory);
                    ee.CurrentValues.SetValues(estimateversion);
                }
                else
                {
                    //dbContext.Projects.AddRange(projects);
                    dbContext.VersionHistory.Add(estimateversion);
                }
                dbContext.SaveChanges();
                versionHistoryID = estimateversion.Id;
            }

            return(versionHistoryID);//estOperation.GetCategories();
        }