Example #1
0
        public DeletePmsResponse DeletePmsConfigDetails(int id)
        {
            var response = new DeletePmsResponse();
            try
            {
                var pmsConfigDetails = DataContext.PmsConfigDetails
                    .Include(x => x.ScoreIndicators)
                    .Single(x => x.Id == id);
                foreach (var scoreIndicator in pmsConfigDetails.ScoreIndicators.ToList())
                {
                    DataContext.ScoreIndicators.Remove(scoreIndicator);
                }
                DataContext.PmsConfigDetails.Remove(pmsConfigDetails);
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "Pms Config Detail item has been deleted successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }
Example #2
0
        public DeletePmsResponse DeletePmsSummary(int id)
        {
            var response = new DeletePmsResponse();
            try
            {
                var pmsSummary = new PmsSummary { Id = id };
                DataContext.PmsSummaries.Attach(pmsSummary);
                DataContext.Entry(pmsSummary).State = EntityState.Deleted;
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "Pms Summary item has been deleted successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }
Example #3
0
        public DeletePmsResponse DeletePmsSummary(int id)
        {
            var response = new DeletePmsResponse();
            try
            {
                var pmsSummary = DataContext.PmsSummaries
                    .Include(x => x.ScoreIndicators)
                    .Include(x => x.PmsConfigs)
                    .Include(x => x.PmsConfigs.Select(y => y.ScoreIndicators))
                    .Include(x => x.PmsConfigs.Select(y => y.PmsConfigDetailsList))
                    .Include(x => x.PmsConfigs.Select(y => y.PmsConfigDetailsList.Select(z => z.ScoreIndicators)))
                    .Single(x => x.Id == id);
                foreach (var scoreIndicator in pmsSummary.ScoreIndicators.ToList())
                {
                    DataContext.ScoreIndicators.Remove(scoreIndicator);
                }

                foreach (var pmsConfig in pmsSummary.PmsConfigs.ToList())
                {
                    foreach (var pmsConfigDetailse in pmsConfig.PmsConfigDetailsList.ToList())
                    {
                        foreach (var score in pmsConfigDetailse.ScoreIndicators.ToList())
                        {
                            DataContext.ScoreIndicators.Remove(score);
                        }

                        DataContext.PmsConfigDetails.Remove(pmsConfigDetailse);
                    }

                    foreach (var score in pmsConfig.ScoreIndicators.ToList())
                    {
                        DataContext.ScoreIndicators.Remove(score);
                    }

                    DataContext.PmsConfigs.Remove(pmsConfig);
                }

                DataContext.PmsSummaries.Remove(pmsSummary);
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message = "Pms Summary item has been deleted successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return response;
        }