/// <summary>
        /// Save And Update Bussiness Type
        /// </summary>
        /// <param name="businessTypeDetails"></param>
        /// <returns></returns>
        public int SaveAndUpdateBusinessType(BusinessTypeDTO businessTypeDetails)
        {
            businesstype businessTypeEntity = new businesstype();
            AutoMapper.Mapper.Map(businessTypeDetails, businessTypeEntity);

            if (businessTypeEntity.BusinessType_Id == 0)
            {
                base.BusinessTypeRepository.Save(businessTypeEntity);
            }
            else
            {
                base.BusinessTypeRepository.Update(businessTypeEntity);
            }
            return businessTypeEntity.BusinessType_Id;
        }
    protected void grdBusinessType_RowCommand(object sender, GridViewCommandEventArgs e)
    {        
        if (e.CommandName == Globals.GridCommandEvents.ADDNEW)
        {
            if (Page.IsValid)
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);

                BusinessTypeDTO businessTypeDetails = new BusinessTypeDTO();
                businessTypeDetails.BusinessType_Name = ((TextBox)row.FindControl("txtNewBusinessType")).Text;
                businessTypeDetails.BusinessType_CreatedDate = DateTime.Now;
                businessTypeDetails.BusinessType_LastUpdatedDate = DateTime.Now;
                businessTypeDetails.BusinessType_CreatedBy = GetCurrentUserId();

                int businessTypeId = ESalesUnityContainer.Container.Resolve<IMasterService>()
                    .SaveAndUpdateBusinessType(businessTypeDetails);
                ucMessageBoxForGrid.ShowMessage(Messages.BusinessTypeSavedSuccessfully);
            }
        }
    }
    protected void grdBusinessType_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (Page.IsValid)
        {            
            BusinessTypeDTO businessType = new BusinessTypeDTO();
            businessType = ESalesUnityContainer.Container.Resolve<IMasterService>()
                .GetBusinessTypeListByTypeId(Convert.ToInt32(grdBusinessType.DataKeys[e.RowIndex].Value));

            businessType.BusinessType_Name = ((TextBox)grdBusinessType.Rows[e.RowIndex].FindControl("txtBusinessType")).Text;
            businessType.BusinessType_LastUpdatedDate = DateTime.Now;
            businessType.BusinessType_CreatedBy = GetCurrentUserId();

            //To update business type
            ESalesUnityContainer.Container.Resolve<IMasterService>().SaveAndUpdateBusinessType(businessType);
            ucMessageBoxForGrid.ShowMessage(Messages.BusinessTypeUpdatedSuccessfully);
        }        
    }
 /// <summary>
 /// Get Business Type List By Type Id
 /// </summary>
 /// <param name="businessTypeId">Int32:businessTypeId</param>
 /// <returns></returns>
 public BusinessTypeDTO GetBusinessTypeListByTypeId(int businessTypeId)
 {
     BusinessTypeDTO objBusinessTypeDTO = new BusinessTypeDTO();
     AutoMapper.Mapper.Map(base.BusinessTypeRepository.GetSingle(item => item.BusinessType_Id == businessTypeId), objBusinessTypeDTO);
     return objBusinessTypeDTO;
 }
        /// <summary>
        /// Verify Business Type Exists or not by businessTypeId and businessType
        /// </summary>
        /// <param name="businessTypeId">Int32:businessTypeId</param>
        /// <param name="businessType">String:businessType</param>
        /// <returns></returns>
        bool IMasterService.IsBusinessTypeExists(int businessTypeId, string businessType)
        {
            BusinessTypeDTO businessTypeDetails = new BusinessTypeDTO();
            bool result = false;

            if (businessTypeId == 0)
            {
                AutoMapper.Mapper.Map(base.BusinessTypeRepository.GetSingle(item => item.BusinessType_Name == businessType 
                    && item.BusinessType_IsDeleted == false), businessTypeDetails);
            }
            else
            {
                AutoMapper.Mapper.Map(base.BusinessTypeRepository.GetSingle(item => item.BusinessType_Name == businessType 
                    && item.BusinessType_IsDeleted == false && item.BusinessType_Id != businessTypeId), 
                    businessTypeDetails);
            }

            if (businessTypeDetails.BusinessType_Id > 0)
            {
                result = true;
            }
            return result;
        }