/// <summary>
        /// Will save the details of authorized representative 
        /// </summary>
        /// <param name="authRepDetails"></param>
        public int SaveAndUpdateAuthRepDetailsForCustomer(AuthRepDTO authRepDetails)
        {
            int authRepId = 0;
            authrepdetail authrepdetailEntity = new authrepdetail();
            AutoMapper.Mapper.Map(authRepDetails, authrepdetailEntity);

            if (authRepDetails.AuthRep_Id == 0)
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>().Save(authrepdetailEntity);
            }
            else
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>().Update(authrepdetailEntity);
            }

            authRepId = authrepdetailEntity.AuthRep_Id;

            //return the details
            return authRepId;
        }
    protected void grdAuthRepCuationLst_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals(Globals.GridCommandEvents.ADDNEW))
        {            
            GridViewRow gvRow = (GridViewRow)((Button)e.CommandSource).NamingContainer;
            AuthRepDTO authRepDetails = new AuthRepDTO();

            authRepDetails = ESalesUnityContainer.Container.Resolve<IAuthRepService>()
                .GetAuthRepById(Convert.ToInt32(((DropDownList)gvRow.FindControl("ddlAuthRep")).SelectedValue));
            authRepDetails.AuthRep_IsBlacklisted = true;
            authRepDetails.AuthRep_IsDeleted = true;
            authRepDetails.AuthRep_BlacklistedBy = ((DropDownList)gvRow.FindControl("ddlBlackListedBy")).SelectedValue;
            
            int authRepId = ESalesUnityContainer.Container.Resolve<ICautionListService>()
                .UpdateCautionListForAuthRep(authRepDetails);
            
            PopulateAuthRepCuationList();
            if (authRepId > 0)
            {
                ucMessageBoxForGrid.ShowMessage(Resources.Messages.AuthRepCautionListCreatedSuccessfully);
            }
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    private AuthRepDTO InitializeAuthRepDetails()
    {
        AuthRepDTO authRepDetails = new AuthRepDTO();
        
        if (ViewState[Globals.StateMgmtVariables.AUTHREPID] != null)
        {
            authRepDetails.AuthRep_Id = Convert.ToInt32(ViewState[Globals.StateMgmtVariables.AUTHREPID]);
        }

        authRepDetails.AuthRep_CustomerId = Convert.ToInt32(ViewState["CustId"]);
        authRepDetails.AuthRep_Name = txtAuthName.Text.Trim();
        authRepDetails.AuthRep_FatherName = txtAuthFatherName.Text.Trim();
        authRepDetails.AuthRep_Address = txtAddress.Text.Trim();
        authRepDetails.AuthRep_Mobile = txtMobileNumber.Text.Trim();
        authRepDetails.AuthRep_CreatedBy = GetCurrentUserId();

        if (authRepDetails.AuthRep_Id > 0)
        {
            authRepDetails.AuthRep_LastUpdatedDate = DateTime.Now;
        }
        else
        {
            authRepDetails.AuthRep_CreatedDate = DateTime.Now;
        }

        //return the value
        return authRepDetails;
    }
        /// <summary>
        /// function to check if dublicacy while creating new Authorize Representative.
        /// </summary>
        /// <param name="authRepName"></param>
        /// <returns></returns>
        public AuthRepDTO GetAuthRepByName(string authRepName)
        {
            AuthRepDTO objAuthRepDTO = new AuthRepDTO();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>()
                .GetSingle(item => item.AuthRep_Name == authRepName && item.AuthRep_IsDeleted == false), objAuthRepDTO);

            //return the value
            return objAuthRepDTO;
        }      
        /// <summary>
        /// Delete Auth Rep
        /// </summary>
        /// <param name="truckDetails"></param>
        public void DeleteAuthRep(AuthRepDTO authRepDetails)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                IList<AuthRepDocDetailDTO> lstAuthRepDocDetails = GetAuthRepDocDetailsByAuthRepId(authRepDetails.AuthRep_Id);

                (from authRepDocDetail in lstAuthRepDocDetails select authRepDocDetail).Update(
                    authRepDocDetail => authRepDocDetail.AuthRep_Doc_IsDeleted = true);

                foreach (var authRepDocs in lstAuthRepDocDetails)
                {
                    DeleteAuthRepDocDetails(authRepDocs);
                }

                authrepdetail authRepEntity = new authrepdetail();
                AutoMapper.Mapper.Map(authRepDetails, authRepEntity);

                ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>().Update(authRepEntity);

                transactionScope.Complete();
            }
        }
        /// <summary>
        /// Get Auth Rep  by authRepId
        /// </summary>
        /// <param name="authRepId"></param>
        /// <returns></returns>
        public AuthRepDTO GetAuthRepById(int authRepId)
        {
            AuthRepDTO objAuthRepDTO = new AuthRepDTO();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>()
                .GetSingle(item => item.AuthRep_Id == authRepId), objAuthRepDTO);

            //return the value
            return objAuthRepDTO;
        }
        /// <summary>
        /// Update Caution List For AuthRep
        /// </summary>
        /// <param name="authRepDetails"></param>
        /// <returns></returns>
        public int UpdateCautionListForAuthRep(AuthRepDTO authRepDetails)
        {
            authrepdetail authrepdetailEntity = new authrepdetail();
            AutoMapper.Mapper.Map(authRepDetails, authrepdetailEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdetail>>().Update(authrepdetailEntity);

            //return value
            return authrepdetailEntity.AuthRep_Id;
        }