示例#1
0
 public RR.MotorProductMasterResponse MotorProductMasterOperation(RR.MotorProductMaster request)
 {
     try
     {
         BLO.MotorProductMaster         req    = _mapper.Map <RR.MotorProductMaster, BLO.MotorProductMaster>(request);
         BLO.MotorProductMasterResponse result = _adminRepository.MotorProductMasterOperation(req);
         return(_mapper.Map <BLO.MotorProductMasterResponse, RR.MotorProductMasterResponse>(result));
     }
     catch (Exception ex)
     {
         return(new RR.MotorProductMasterResponse
         {
             IsTransactionDone = false,
             TransactionErrorMessage = ex.Message
         });
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string opertaion = string.Empty;

                master.IsSessionAvailable();
                var userInfo = CommonMethods.GetUserDetails();
                var service  = CommonMethods.GetLogedInService();

                var request = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorProductMaster
                {
                    Agency    = userInfo.Agency,
                    AgentCode = userInfo.AgentCode,
                    MainClass = txtMainClass.Text.Trim(),
                    SubClass  = txtSubClass.Text.Trim(),

                    AgeLoadingPercent = string.IsNullOrEmpty(txtAgeLoadingPercent.Text) ? decimal.Zero :
                                        Convert.ToDecimal(txtAgeLoadingPercent.Text),

                    ExcessAmount = string.IsNullOrEmpty(txtExcessAmount.Text) ? decimal.Zero :
                                   Convert.ToDecimal(txtExcessAmount.Text),

                    GCCCoverRangeInYears = string.IsNullOrEmpty(txtGCCCoverRangeInYears.Text) ? 0 :
                                           Convert.ToInt32(txtGCCCoverRangeInYears.Text),

                    LastSeries = string.IsNullOrEmpty(txtLastSeries.Text) ? 0 :
                                 Convert.ToInt64(txtLastSeries.Text),

                    MaximumVehicleAge = string.IsNullOrEmpty(txtMaximumVehicleAge.Text) ? 0 :
                                        Convert.ToInt32(txtMaximumVehicleAge.Text),

                    MaximumVehicleValue = string.IsNullOrEmpty(txtMaximumVehicleValue.Text) ? 0 :
                                          Convert.ToDecimal(txtMaximumVehicleValue.Text),

                    MinimumPremium = string.IsNullOrEmpty(txtMinimumPremium.Text) ? 0 :
                                     Convert.ToDecimal(txtMinimumPremium.Text),

                    Rate = string.IsNullOrEmpty(txtRate.Text) ? decimal.Zero :
                           Convert.ToDecimal(txtRate.Text),

                    SeriesFormatLength = string.IsNullOrEmpty(txtSeriesFormatLength.Text) ? 0 :
                                         Convert.ToInt32(txtSeriesFormatLength.Text),

                    UnderAge = string.IsNullOrEmpty(txtUnderAge.Text) ? 0 :
                               Convert.ToInt32(txtUnderAge.Text),

                    UnderAgeExcessAmount = string.IsNullOrEmpty(txtUnderAgeExcessAmount.Text) ? 0 :
                                           Convert.ToDecimal(txtUnderAgeExcessAmount.Text),

                    UnderAgeminPremium = string.IsNullOrEmpty(txtUnderAgeMinimumPremium.Text) ? 0 :
                                         Convert.ToDecimal(txtUnderAgeMinimumPremium.Text),

                    GulfAssitAmount = string.IsNullOrEmpty(txtGulfAssitAmount.Text) ? 0 :
                                      Convert.ToDecimal(txtGulfAssitAmount.Text),

                    UnderAgeToHIR      = chkUnderAgeToHIR.Checked,
                    HasAdditionalDays  = chkHasAdditionalDays.Checked,
                    HasAgeLoading      = chkHasAgeLoading.Checked,
                    HasGCC             = chkHasGCC.Checked,
                    AllowUnderAge      = chkAllowUnderAge.Checked,
                    AllowMaxVehicleAge = chkAllowMaximumVehicleAge.Checked,
                    Description        = txtDescription.Text.Trim(),
                    PolicyCode         = txtPolicyCode.Text.Trim(),
                    AllowUsedVehicle   = chkAllowUsedVehicle.Checked
                };

                opertaion = (sender as Button).Text;
                if (opertaion == "Update")
                {
                    // request.ID = Convert.ToInt32(ViewState["Id"].ToString());
                    request.Type = "edit";
                }
                else
                {
                    request.Type = "insert";
                }

                var motorProduct = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                     <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorProductMasterResponse>,
                                                     BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorProductMaster>
                                       (BKIC.SellingPoint.DTO.Constants.AdminURI.MotorProductOperation, request);

                if (motorProduct != null && motorProduct.StatusCode == 200 && motorProduct.Result.IsTransactionDone)
                {
                    ClearProduct();
                    if (request.Type == "insert")
                    {
                        master.ShowErrorPopup("Motor product added successfully", "Motor Product");
                    }
                    else if (request.Type == "edit")
                    {
                        master.ShowErrorPopup("Motor product updated successfully", "Motor Product");
                    }
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            finally
            {
                master.ShowLoading = false;
            }
        }