public void saveDefaultCovers(int jobId, UserAccount user) { QuotationMain quotationMain; QuotationMainController quotationMainController = new QuotationMainController(); quotationMain = quotationMainController.Get(Convert.ToInt32(jobId)); if (user.Company != Properties.Settings.Default.MNBQGeneralCompanyName) { string[] defaultCoverCodes = new string[5]; defaultCoverCodes[0] = "chk18"; //Flood defaultCoverCodes[1] = "chk19"; //Natural Perils defaultCoverCodes[2] = "chk24"; //Adjustment Fee defaultCoverCodes[3] = "chk26"; //SRCC - for Vehicles defaultCoverCodes[4] = "multiple rebate"; for (int a = 0; a < defaultCoverCodes.Length; a++) { if (defaultCoverCodes[a] == "multiple rebate") { double allowedMaxMR = 0.00; MRRateController mRRateController = new MRRateController(); allowedMaxMR = mRRateController.getRelevantMRRate(quotationMain.RiskTypeId, quotationMain.VehicleUsageId, quotationMain.FuelTypeCode, quotationMain.SumInsured, user.Company, quotationMain.MakeModelCode, quotationMain.YearOfManufactureValidationId); SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, defaultCoverCodes[a], "0", allowedMaxMR.ToString()); } else { SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, defaultCoverCodes[a], "0", "0"); } } //save stamp duty for private if (quotationMain.VehicleUsageId == Properties.Settings.Default.MNBQUsagePrivate) { SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, "chk20", "0", "0"); } //Up front ncb - 1 year if (!new int[] { Properties.Settings.Default.MNBQMotorCycleRiskTypeId, Properties.Settings.Default.MNBQThreeWheelerRiskType }.Contains(quotationMain.RiskTypeId)) { if (!new int[] { Properties.Settings.Default.FuelTypeElectric, Properties.Settings.Default.FuelTypeHybrid }.Contains(quotationMain.FuelTypeCode)) { SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, "chk10", "1 Year", "20"); } } // Inclusion of Excluded Items for hiring if (quotationMain.VehicleUsageId == Properties.Settings.Default.MNBQUsageHiring) { SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, "chk14", "0", "0"); } // TPPD - for vehicles except Motor Car(Private) if (quotationMain.RiskTypeId == Properties.Settings.Default.MNBQMotorCarRiskTypeId && quotationMain.VehicleUsageId == Properties.Settings.Default.MNBQUsagePrivate) { } else { SaveDefaultCovers(quotationMain.JobId, quotationMain.RevisionNo, "chk12", "500,000.00", "0"); } } }
public string AddQuotationCoverDetails(PostQuotationCoverRequest postQuotationCoverRequest) { // api/QuotationCover/AddQuotationCoverDetails?jobId=54163&RevisionId=0 var uIdentity = Thread.CurrentPrincipal.Identity; UserAccountController uc = new UserAccountController(); UserAccount user = uc.getUserFromUserName(uIdentity.Name.ToString()); QuotationMainController quotationMainController = new QuotationMainController(); QuotationMain quotationMain; CoverController coverController = new CoverController(); List <Cover> allowedCoverList = coverController.GetAllowedCovers(user.Company); DeleteCovers(Convert.ToInt32(postQuotationCoverRequest.JobId), Convert.ToInt32(postQuotationCoverRequest.RevisionId)); foreach (QuotationCover cover in postQuotationCoverRequest.QuotationCovers) { if (cover.Cover == "chk4" || cover.Cover == "chk5" || cover.Cover == "chk8") { if (!validateCoverAmount(cover.Cover, cover.Amount)) { var message = string.Format("Amount of cover {0} not in the allowed range", cover.Cover); // HttpError err = new HttpError(message); return(message); } } //To validate the allowed covers var item = allowedCoverList.Find(x => x.CoverCode == cover.Cover); if (item == null) { continue; } /////////// OracleConnection con = new OracleConnection(ConnectionString); try { con.Open(); OracleCommand cmd = null; cmd = new OracleCommand("MNB_INSERT_MOTOR_COVER_DETAILS"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.Add("jobid", OracleType.Int32).Value = cover.JobId; cmd.Parameters.Add("revision_id", OracleType.VarChar).Value = cover.RevisionId; cmd.Parameters.Add("cover", OracleType.VarChar).Value = cover.Cover; cmd.Parameters.Add("pol_type", OracleType.VarChar).Value = cover.Type; cmd.Parameters.Add("amount", OracleType.VarChar).Value = cover.Amount; cmd.ExecuteNonQuery(); con.Close(); // saveDefaultCovers(postQuotationCoverRequest.JobId, user); } catch (Exception ex) { con.Close(); return("error"); } } return("ok"); }