public void SaveRecord(DeviationViewModel deviationViewModel)
        {
            using (var context = new MangalDBNewEntities())
            {
                using (DbContextTransaction dbTran = context.Database.BeginTransaction())
                {
                    try
                    {
                        //save  ROI
                        foreach (var p in deviationViewModel.roiDeviationDetailsList)
                        {
                            var roitrn = new Mst_ChildDeviation
                            {
                                ParentId             = 1,
                                ApproveDistanceLimit = 0,
                                MinRange             = p.RoiMinRange,
                                MaxRange             = p.RoiMaxRange,
                                UserCategoryId       = p.RoiUserNo,
                                ThreasoldLimit       = 0,
                                RecordCreatedBy      = deviationViewModel.CreatedBy,
                                RecordCreated        = DateTime.Now,
                                RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                                RecordUpdated        = DateTime.Now,
                            };
                            context.Mst_ChildDeviation.Add(roitrn);
                        }

                        //Save Distance
                        foreach (var p in deviationViewModel.distanceDeviationDetailsList)
                        {
                            var distancetrn = new Mst_ChildDeviation
                            {
                                ParentId             = 2,
                                ApproveDistanceLimit = deviationViewModel.ApproveDistanceLimit,
                                MinRange             = p.DistanceMinRange,
                                MaxRange             = p.DistanceMaxRange,
                                UserCategoryId       = p.DistanceUserNo,
                                ThreasoldLimit       = 0,
                                RecordCreatedBy      = deviationViewModel.CreatedBy,
                                RecordCreated        = DateTime.Now,
                                RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                                RecordUpdated        = DateTime.Now,
                            };
                            context.Mst_ChildDeviation.Add(distancetrn);
                        }

                        //Save Distance
                        var ornamenttrn = new Mst_ChildDeviation
                        {
                            ParentId             = 3,
                            ApproveDistanceLimit = 0,
                            MinRange             = 0,
                            MaxRange             = 0,
                            UserCategoryId       = deviationViewModel.OrnamentUserNo,
                            ThreasoldLimit       = 0,
                            RecordCreatedBy      = deviationViewModel.CreatedBy,
                            RecordCreated        = DateTime.Now,
                            RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                            RecordUpdated        = DateTime.Now,
                        };
                        context.Mst_ChildDeviation.Add(ornamenttrn);

                        //Save Sanction loan amount
                        foreach (var p in deviationViewModel.sanctionDeviationList)
                        {
                            var sanctiontrn = new Mst_ChildDeviation
                            {
                                ParentId             = 4,
                                ApproveDistanceLimit = 0,
                                MinRange             = p.SanctionMinRange,
                                MaxRange             = p.SanctionMaxRange,
                                UserCategoryId       = p.SanctionedUserNo,
                                ThreasoldLimit       = 0,
                                RecordCreatedBy      = deviationViewModel.CreatedBy,
                                RecordCreated        = DateTime.Now,
                                RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                                RecordUpdated        = DateTime.Now,
                            };
                            context.Mst_ChildDeviation.Add(sanctiontrn);
                        }

                        //Save Sanction loan amount
                        foreach (var p in deviationViewModel.tenureDeviationList)
                        {
                            var sanctiontrn = new Mst_ChildDeviation
                            {
                                ParentId             = 5,
                                ApproveDistanceLimit = 0,
                                MinRange             = p.TenureMinRange,
                                MaxRange             = p.TenureMaxRange,
                                UserCategoryId       = p.TenureUserNo,
                                ThreasoldLimit       = 0,
                                RecordCreatedBy      = deviationViewModel.CreatedBy,
                                RecordCreated        = DateTime.Now,
                                RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                                RecordUpdated        = DateTime.Now,
                            };
                            context.Mst_ChildDeviation.Add(sanctiontrn);
                        }

                        //save thresold amount
                        var thrsholdntrn = new Mst_ChildDeviation
                        {
                            ParentId             = 6,
                            ApproveDistanceLimit = 0,
                            MinRange             = 0,
                            MaxRange             = 0,
                            UserCategoryId       = 0,
                            ThreasoldLimit       = deviationViewModel.ThresholdLimit,
                            RecordCreatedBy      = deviationViewModel.CreatedBy,
                            RecordCreated        = DateTime.Now,
                            RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                            RecordUpdated        = DateTime.Now,
                        };
                        context.Mst_ChildDeviation.Add(thrsholdntrn);

                        //Save LTV %
                        foreach (var p in deviationViewModel.lTVDeviationDetailsList)
                        {
                            var sanctiontrn = new Mst_ChildDeviation
                            {
                                ParentId             = 7,
                                ApproveDistanceLimit = 0,
                                MinRange             = p.LTVMinRange,
                                MaxRange             = p.LTVMaxRange,
                                UserCategoryId       = p.LTVUserNo,
                                ThreasoldLimit       = 0,
                                RecordCreatedBy      = deviationViewModel.CreatedBy,
                                RecordCreated        = DateTime.Now,
                                RecordUpdatedBy      = deviationViewModel.UpdatedBy,
                                RecordUpdated        = DateTime.Now,
                            };
                            context.Mst_ChildDeviation.Add(sanctiontrn);
                        }
                        context.SaveChanges();
                        dbTran.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        dbTran.Rollback();
                        throw ex;
                    }
                }
            }
        }
 public ForgotPasswordController()
 {
     _context = new MangalDBNewEntities();
 }
Beispiel #3
0
 public UserAuthorizationRepository()
 {
     _context = new MangalDBNewEntities();
 }