/// <summary>
 /// Get customer authorization details by cutomer id
 /// </summary>
 /// <param name="customerId">Int32: customer id</param>
 /// <returns>returns customer authorization details object</returns>
 public CustAuthorizationDetailDTO GetCustomerAuthorizationDetails(int customerId)
 {
     CustAuthorizationDetailDTO custAuthDetails = new CustAuthorizationDetailDTO();
     AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<custauthorizationdetail>>()
     .GetSingle(item => item.CustAuth_CustId == customerId), custAuthDetails);
     return custAuthDetails;
 }
        /// <summary>
        /// Save And Update Customer Authorization Details
        /// </summary>
        /// <param name="custAuthorizationDetail"></param>
        public void SaveAndUpdateCustomerAuthorizationDetails(CustAuthorizationDetailDTO custAuthorizationDetail)
        {
            custauthorizationdetail custAuthorizationEntity = new custauthorizationdetail();
            AutoMapper.Mapper.Map(custAuthorizationDetail, custAuthorizationEntity);

            if (custAuthorizationDetail.CustAuth_Id == 0)
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<custauthorizationdetail>>()
                    .Save(custAuthorizationEntity);
            }
            else
            {
                ESalesUnityContainer.Container.Resolve<IGenericRepository<custauthorizationdetail>>()
                    .Update(custAuthorizationEntity);
            }
        }
	private CustAuthorizationDetailDTO InitializeCustomerAuthorizationDetails()
	{
		CustAuthorizationDetailDTO custAuthorizationDetail = new CustAuthorizationDetailDTO();
        custAuthorizationDetail.CustAuth_CustId = (Convert.ToInt32(ViewState[Globals.StateMgmtVariables.CUSTOMERID]));
		custAuthorizationDetail.CustAuth_Date = DateTime.Now;
        custAuthorizationDetail.CustAuth_Status = true;
        custAuthorizationDetail.CustAuth_CreatedBy = GetCurrentUserId();
        custAuthorizationDetail.CustAuth_CreatedDate = DateTime.Now;

        //If fileupload control has file
        if (filAuthDoc.HasFile)
		{
            string uploadFilePath = Path.Combine(Server.MapPath("../CustomerAuthImages"), filAuthDoc.FileName);
            filAuthDoc.SaveAs(uploadFilePath);
            
            custAuthorizationDetail.CustAuth_File = ImageToBlob.ConvertImageToByteArray(uploadFilePath);
            custAuthorizationDetail.CustAuth_FileName = filAuthDoc.FileName;

            //Delete the file from application folder after converting into byte array
            File.Delete(uploadFilePath);
		}        
        return custAuthorizationDetail;
	}