예제 #1
0
 //    [ApiAuthorize(BKIC.SellingPont.DTO.Constants.Roles.SuperAdmin)]
 public RR.BranchMasterResponse PostBranchDetails(RR.BranchMaster request)
 {
     try
     {
         BLO.BranchMaster         req    = _mapper.Map <RR.BranchMaster, BLO.BranchMaster>(request);
         BLO.BranchMasterResponse result = _adminRepository.BranchOperation(req);
         return(_mapper.Map <BLO.BranchMasterResponse, RR.BranchMasterResponse>(result));
     }
     catch (Exception ex)
     {
         return(new RR.BranchMasterResponse
         {
             IsTransactionDone = false,
             TransactionErrorMessage = ex.Message
         });
     }
 }
        protected void lnkbtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)
                {
                    master.IsSessionAvailable();
                    var userInfo = CommonMethods.GetUserDetails();
                    var service  = CommonMethods.GetLogedInService();

                    int id = Convert.ToInt32(HttpUtility.HtmlDecode(row.Cells[1].Text.Trim()));

                    var branchdetails = new BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMaster();

                    branchdetails.Id   = id;
                    branchdetails.Type = "delete";

                    var branchResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMasterResponse>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMaster>
                                           (BKIC.SellingPoint.DTO.Constants.AdminURI.BranchDetailsOperation, branchdetails);
                    if (branchResult.StatusCode == 200 && branchResult.Result.IsTransactionDone)
                    {
                        LoadBranchData(userInfo, service);
                        ClearControl();
                        ddlAgency.SelectedIndex = ddlAgency.Items.IndexOf(ddlAgency.Items.FindByText(userInfo.Agency));
                        master.ShowErrorPopup("Branch details deleted successfuly", "Branch");
                        btnSubmit.Text = "Save";
                    }
                }
            }
            catch (Exception ex)
            {
                ////throw ex;
            }
            finally
            {
                master.ShowLoading = false;
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    string opertaion = string.Empty;

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

                    var branchdetails = new BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMaster();

                    branchdetails.Agency      = ddlAgency.SelectedItem.Text.Trim();
                    branchdetails.AgentCode   = ddlAgency.SelectedItem.Value.ToString();
                    branchdetails.AgentBranch = txtAgentBranch.Text.Trim();
                    branchdetails.BranchName  = txtBranchName.Text.Trim();
                    //branchdetails.BranchAddress = txtBranchAddress.Text.ToString();
                    branchdetails.Phone     = txtPhone.Text.Trim();
                    branchdetails.Email     = txtEmail.Text.Trim();
                    branchdetails.Incharge  = txtIncharge.Text.Trim();
                    branchdetails.CreatedBy = "";

                    opertaion = (sender as Button).Text;

                    if (opertaion == "Update")
                    {
                        branchdetails.Id   = Convert.ToInt32(ViewState["BrnachId"].ToString());
                        branchdetails.Type = "edit";
                    }
                    else
                    {
                        branchdetails.Type = "insert";
                    }

                    var branchResult = service.PostData <BKIC.SellingPoint.DTO.RequestResponseWrappers.ApiResponseWrapper
                                                         <BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMasterResponse>,
                                                         BKIC.SellingPoint.DTO.RequestResponseWrappers.BranchMaster>
                                           (BKIC.SellingPoint.DTO.Constants.AdminURI.BranchDetailsOperation, branchdetails);

                    if (branchResult.StatusCode == 200 && branchResult.Result.IsTransactionDone)
                    {
                        LoadBranchData(userInfo, service);
                        ClearControl();
                        ddlAgency.SelectedIndex = ddlAgency.Items.IndexOf(ddlAgency.Items.FindByText(userInfo.Agency));

                        if (branchdetails.Type == "insert")
                        {
                            master.ShowErrorPopup("Branch details saved sucessfully", "Branch");
                        }
                        else
                        {
                            master.ShowErrorPopup("Branch details updated sucessfully", "Branch");
                        }
                        //btnSubmit.Text = (branchdetails.Type == "edit") ? "Save" : "Update";
                        btnSubmit.Text = "Save";
                    }
                }
            }
            catch (Exception ex)
            {
                ////throw ex;
            }
            finally
            {
                master.ShowLoading = false;
            }
        }