protected void lnkbtnDelete_Click(object sender, EventArgs e)
        {
            master.IsSessionAvailable();
            var userInfo = CommonMethods.GetUserDetails();
            var service  = CommonMethods.GetLogedInService();

            using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)
            {
                int id      = Convert.ToInt32(row.Cells[1].Text.Trim());
                var details = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster
                {
                    ID   = id,
                    Type = "delete"
                };

                var vehicleResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                      <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMasterResponse>,
                                                      BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster>
                                        (BKIC.SellingPoint.DTO.Constants.AdminURI.MotorVehicleOperation, details);

                if (vehicleResult.StatusCode == 200 && vehicleResult.Result.IsTransactionDone)
                {
                    LoadVehicle(userInfo, service);
                    master.ShowErrorPopup("Motor vehicle deleted successfully", "Motor Vehicle");
                }
            }
        }
Exemplo n.º 2
0
 public RR.MotorVehicleMasterResponse MotorVehicleOperation(RR.MotorVehicleMaster request)
 {
     try
     {
         BLO.MotorVehicleMaster         req    = _mapper.Map <RR.MotorVehicleMaster, BLO.MotorVehicleMaster>(request);
         BLO.MotorVehicleMasterResponse result = _adminRepository.MotorVehicleMasterOperation(req);
         return(_mapper.Map <BLO.MotorVehicleMasterResponse, RR.MotorVehicleMasterResponse>(result));
     }
     catch (Exception ex)
     {
         return(new RR.MotorVehicleMasterResponse
         {
             IsTransactionDone = false,
             TransactionErrorMessage = ex.Message
         });
     }
 }
        private void LoadVehicle(OAuthTokenResponse userInfo, DataServiceManager service)
        {
            var request = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster
            {
                Type = "fetch",
                Make = txtMakeSearch.Text.Trim()
            };
            var results = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                            <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMasterResponse>,
                                            BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster>
                              (BKIC.SellingPoint.DTO.Constants.AdminURI.MotorVehicleOperation, request);

            if (results.StatusCode == 200 && results.Result.IsTransactionDone)
            {
                gvMotorVehicle.DataSource = results.Result.MotorVehicleMaster;
                gvMotorVehicle.DataBind();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    string opertaion = string.Empty;

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

                    var details = new BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster
                    {
                        Make            = txtMake.Text.Trim(),
                        Model           = txtModel.Text.Trim(),
                        Body            = txtBodyType.Text.Trim(),
                        Tonnage         = string.IsNullOrEmpty(txtCapacity.Text) ? 0 : Convert.ToInt32(txtCapacity.Text),
                        NewExcessAmount = string.IsNullOrEmpty(txtExcess.Text) ? 0 : Convert.ToDecimal(txtExcess.Text),
                        VehicleValue    = string.IsNullOrEmpty(txtCapacity.Text) ? 0 : Convert.ToInt32(txtCapacity.Text),
                        SeatingCapacity = string.IsNullOrEmpty(txtSeatingCapacity.Text) ? 0 : Convert.ToInt32(txtSeatingCapacity.Text),
                        Year            = string.IsNullOrEmpty(txtYear.Text) ? 0 : Convert.ToInt32(txtYear.Text),
                        VehicleType     = "",
                        // details.Category = "";
                    };
                    opertaion = (sender as Button).Text;
                    if (opertaion == "Update")
                    {
                        details.ID   = Convert.ToInt32(ViewState["Id"].ToString());
                        details.Type = "update";
                    }
                    else
                    {
                        details.Type = "insert";
                    }

                    var results = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                    <BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMasterResponse>,
                                                    BKIC.SellingPoint.DTO.RequestResponseWrappers.MotorVehicleMaster>
                                      (BKIC.SellingPoint.DTO.Constants.AdminURI.MotorVehicleOperation, details);

                    if (results.StatusCode == 200 && results.Result.IsTransactionDone)
                    {
                        btnSubmit.Text = "Save";
                        if (details.Type == "insert")
                        {
                            master.ShowErrorPopup("Motor vehicle added successfully", "Motor Vehicle");
                        }
                        if (details.Type == "Update")
                        {
                            master.ShowErrorPopup("Motor vehicle updated successfully", "Motor Vehicle");
                        }
                        LoadVehicle(userInfo, service);
                        ClearControls();
                    }
                    else
                    {
                        master.ShowErrorPopup(results.Result.TransactionErrorMessage, "Request Failed!");
                    }
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            finally
            {
                master.ShowLoading = false;
            }
        }