/// <summary>
        /// Delete Standalone TruckDoc Details
        /// </summary>
        /// <param name="standaloneTruckDocs"></param>
        private static void DeleteStandaloneTruckDocDetails(StandaloneTruckDocDetails standaloneTruckDocs)
        {
            standalonetruckdocdetail standaloneTruckDocEntity = new standalonetruckdocdetail();
            AutoMapper.Mapper.Map(standaloneTruckDocs, standaloneTruckDocEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<standalonetruckdocdetail>>()
                .Update(standaloneTruckDocEntity);
        }
    private void SaveDocumentListForTruck(string truckNo)
    {
        TruckVerificationDTO truckDetails = new TruckVerificationDTO();
        truckDetails = ESalesUnityContainer.Container.Resolve<ITruckService>().GetAllTruckDetails(truckNo);

        IList<TruckDocDetailsDTO> listTruckDocDetail = new List<TruckDocDetailsDTO>();
        IList<TruckDocumentsDTO> listTruckDocument = new List<TruckDocumentsDTO>();
        IList<StandaloneTruckDocDetails> listStandaloneTruckDocDetail = new List<StandaloneTruckDocDetails>();

        foreach (GridViewRow row in grdDocument.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                if (((TextBox)(row.Cells[2].Controls[1])).Text != string.Empty)
                {
                    if (truckDetails.type == 1)
                    {
                        TruckDocDetailsDTO truckDocDetails = new TruckDocDetailsDTO();
                        truckDocDetails.Truck_Doc_TruckId = Convert.ToInt32(ViewState[Globals.StateMgmtVariables.TRUCKID]);
                        truckDocDetails.Truck_Doc_DocId = Convert.ToInt32(grdDocument.DataKeys[row.RowIndex].Value);
                        truckDocDetails.Truck_Doc_DocNo = ((TextBox)(row.Cells[2].Controls[1])).Text;

                        DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;
                        dateTimeFormatterProvider.ShortDatePattern = "dd/MM/yyyy";
                        if (((TextBox)(row.Cells[3].Controls[1])).Text != string.Empty)
                        {
                            truckDocDetails.Truck_Doc_ExDate = DateTime.Parse(((TextBox)(row.Cells[3].Controls[1])).Text, dateTimeFormatterProvider);
                        }

                        TruckDocumentsDTO truckDocument = new TruckDocumentsDTO();
                        truckDocument.TruckDoc_CreatedBy = base.GetCurrentUserId();
                        truckDocument.TruckDoc_CreatedDate = DateTime.Now;
                        truckDocument.TruckDoc_LastUpdatedDate = DateTime.Now;

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

                            truckDocument.TruckDoc_File = ImageToBlob.ConvertImageToByteArray(uploadFilePath);
                            truckDocDetails.Truck_Doc_FileName = filAuthDoc.FileName;
                            //Delete the file from application folder after converting into byte array
                            File.Delete(uploadFilePath);
                        }
                        else
                        {
                            truckDocument.TruckDoc_File = null;
                        }

                        listTruckDocument.Add(truckDocument);

                        truckDocDetails.Truck_Doc_CreatedBy = GetCurrentUserId();
                        truckDocDetails.Truck_Doc_CreatedDate = DateTime.Now;
                        truckDocDetails.Truck_Doc_LastUpdatedDate = DateTime.Now;

                        listTruckDocDetail.Add(truckDocDetails);

                        ESalesUnityContainer.Container.Resolve<ITruckService>().SaveAndUpdateTruckDocumentDetails(listTruckDocDetail, listTruckDocument);
                    }
                    else if (truckDetails.type == 2)
                    {
                        StandaloneTruckDocDetails standaloneTruckDocDetails = new StandaloneTruckDocDetails();
                        standaloneTruckDocDetails.StandaloneTruck_Doc_TruckId = Convert.ToInt32(ViewState[Globals.StateMgmtVariables.TRUCKID]);
                        standaloneTruckDocDetails.StandaloneTruck_Doc_DocId = Convert.ToInt32(grdDocument.DataKeys[row.RowIndex].Value);
                        standaloneTruckDocDetails.StandaloneTruck_Doc_DocNo = ((TextBox)(row.Cells[2].Controls[1])).Text;

                        if (((TextBox)(row.Cells[3].Controls[1])).Text != string.Empty)
                        {
                            standaloneTruckDocDetails.StandaloneTruck_Doc_ExDate = DateTime.Parse(((TextBox)(row.Cells[3].Controls[1])).Text.ToString());
                        }

                        if (filAuthDoc.HasFile)
                        {
                            string uploadFilePath = Path.Combine(Server.MapPath("../CustomerAuthImages"), filAuthDoc.FileName);
                            filAuthDoc.SaveAs(uploadFilePath);

                            standaloneTruckDocDetails.StandaloneTruck_Doc_File = ImageToBlob.ConvertImageToByteArray(uploadFilePath);
                            standaloneTruckDocDetails.StandaloneTruck_Doc_FileName = filAuthDoc.FileName;
                            File.Delete(uploadFilePath);
                        }
                        else
                        {
                            standaloneTruckDocDetails.StandaloneTruck_Doc_File = null;
                        }
                        standaloneTruckDocDetails.StandaloneTruck_Doc_CreatedBy = GetCurrentUserId();
                        standaloneTruckDocDetails.StandaloneTruck_Doc_CreatedDate = DateTime.Now;
                        standaloneTruckDocDetails.StandaloneTruck_Doc_LastUpdatedDate = DateTime.Now;

                        listStandaloneTruckDocDetail.Add(standaloneTruckDocDetails);

                        ESalesUnityContainer.Container.Resolve<IStandaloneTruckService>().SaveAndUpdateStandaloneTruckDocumentDetails(listStandaloneTruckDocDetail);
                    }
                }
            }
        }
    }
        /// <summary>
        /// Get Standalone Truck Doc Details By TruckId And DocId
        /// </summary>
        /// <param name="truckId">Int32:truckId</param>
        /// <param name="documentId">Int32:documentId</param>
        /// <returns></returns>
        public StandaloneTruckDocDetails GetStandaloneTruckDocDetailsByTruckIdAndDocId(int truckId, int documentId)
        {
            StandaloneTruckDocDetails objTruckDocDetails = new StandaloneTruckDocDetails();
            standalonetruckdocdetail TruckDocDetailsEntity = ESalesUnityContainer.Container
                .Resolve<IGenericRepository<standalonetruckdocdetail>>()
                .GetSingle(item => item.StandaloneTruck_Doc_TruckId == truckId && item.StandaloneTruck_Doc_DocId == documentId && item.StandaloneTruck_Doc_IsDeleted == false);

            AutoMapper.Mapper.Map(TruckDocDetailsEntity, objTruckDocDetails);

            //return the value
            return objTruckDocDetails;
        }
    private IList<StandaloneTruckDocDetails> InitializeDocumentListForStandaloneTrucks(int truckId)
    {
        IList<StandaloneTruckDocDetails> lstTruckDetails = new List<StandaloneTruckDocDetails>();
        foreach (GridViewRow row in grdDocument.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                if (((TextBox)(row.Cells[3].Controls[1])).Text != string.Empty)
                {
                    StandaloneTruckDocDetails truckDocDetail = new StandaloneTruckDocDetails();
                    truckDocDetail.StandaloneTruck_Doc_TruckId = truckId;
                    truckDocDetail.StandaloneTruck_Doc_DocId = Convert.ToInt32(grdDocument.DataKeys[row.RowIndex].Value);
                    truckDocDetail.StandaloneTruck_Doc_DocNo = ((TextBox)(row.Cells[3].Controls[1])).Text;
                    HiddenField hdnFileName = (HiddenField)row.FindControl("hdnFileName");
                    DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;
                    dateTimeFormatterProvider.ShortDatePattern = "dd/MM/yyyy";
                    truckDocDetail.StandaloneTruck_Doc_ExDate = DateTime.Parse(((TextBox)(row.Cells[4].Controls[1])).Text, dateTimeFormatterProvider);

                    if (((Label)(row.Cells[6].Controls[1])).Text.Trim() != string.Empty)
                    {
                        if (hdnFileName.Value == string.Empty)
                        {
                            string filePath = Path.Combine(Globals.FolderDetails.FOLDERPATH, Globals.FolderDetails.STANDALONETRUCKFOLDER);
                            filePath = Path.Combine(filePath, ((Label)(row.Cells[6].Controls[1])).Text);
                            truckDocDetail.StandaloneTruck_Doc_File = ImageToBlob.ConvertImageToByteArray(filePath);
                        }
                        else
                        {
                            string strBytes = ((HiddenField)(row.FindControl("hdnImge"))).Value;
                            string str = strBytes.Substring(1, strBytes.Length - 2);
                            string[] arr = str.Split(',');

                            byte[] rawData = Array.ConvertAll(arr, Convert.ToByte);
                            truckDocDetail.StandaloneTruck_Doc_File = rawData;
                        }
                    }
                    else
                    {
                        ((TextBox)(row.Cells[3].Controls[1])).Text = string.Empty;
                        ((TextBox)(row.Cells[4].Controls[1])).Text = string.Empty;
                        truckDocDetail.StandaloneTruck_Doc_File = null;
                    }

                    truckDocDetail.StandaloneTruck_Doc_FileName = ((Label)(row.Cells[6].Controls[1])).Text;
                    truckDocDetail.StandaloneTruck_Doc_CreatedBy = GetCurrentUserId();
                    truckDocDetail.StandaloneTruck_Doc_CreatedDate = DateTime.Now;
                    truckDocDetail.StandaloneTruck_Doc_LastUpdatedDate = DateTime.Now;
                    lstTruckDetails.Add(truckDocDetail);
                }
            }
        }
        return lstTruckDetails;
    }