/// <summary>
 /// Save booking mode details in database
 /// </summary>
 /// <param name="bookingModeDetails">values of BbookingModeDetails object</param>
 /// <returns>returns integer value indicating if records saved in database</returns>
 public int SaveBookingModeDetails(BookingModeDetailDTO bookingModeDetails)
 {
     bookingmodedetail bookingModeDetailEntity = new bookingmodedetail();
     AutoMapper.Mapper.Map(bookingModeDetails, bookingModeDetailEntity);
     if (bookingModeDetailEntity.BookingDetails_Id > 0)
     {
         ESalesUnityContainer.Container.Resolve<IGenericRepository<bookingmodedetail>>().Update(bookingModeDetailEntity);
     }
     else
     {
         ESalesUnityContainer.Container.Resolve<IGenericRepository<bookingmodedetail>>().Save(bookingModeDetailEntity);
     }
     return bookingModeDetailEntity.BookingDetails_Id;
 }
        /// <summary>
        /// Verifies if booking mode id already exists for a day
        /// </summary>
        /// <param name="bookingModeId">booking mode id to be checked for duplicity</param>
        /// <returns>returns true if booking mode id exists in database, false otherwise</returns>
        public bool VerifyDuplicateBookingMode(int bookingModeId)
        {
            bool result = false;
            DateTime currentDate = DateTime.Now.Date;
            BookingModeDetailDTO bookingModeDetail = new BookingModeDetailDTO();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<bookingmodedetail>>()
                    .GetSingle(item => item.BookingDetails_Date == currentDate && item.BookingDetails_IsDeleted==false
                        && item.BookingDetails_Mode_Id == bookingModeId), bookingModeDetail);

            //If booking mode id already exists
            if (bookingModeDetail.BookingDetails_Id > 0)
            {
                result = true;
            }
            return result;
        }
 /// <summary>
 /// Initialize booking mode detail values
 /// </summary>
 /// <param name="row">Footer row from Gridview</param>
 /// <returns>returns booking mode detail object</returns>
 private BookingModeDetailDTO InitializeBookingModeDetails(GridViewRow row)
 {
     BookingModeDetailDTO bookingModeDetails = new BookingModeDetailDTO();
     bookingModeDetails.BookingDetails_Mode_Id = Convert.ToInt32(((DropDownList)row.FindControl("ddlBookingMode")).SelectedItem.Value);
     bookingModeDetails.BookingDetails_Date = DateTime.Today;
     string startTime = ((DropDownList)row.FindControl("ddlStartTime")).SelectedItem.Text;
     bookingModeDetails.BookingDetails_StartTime = new TimeSpan(Convert.ToDateTime(startTime).Hour, Convert.ToDateTime(startTime).Minute, 0);
     string endTime = ((DropDownList)row.FindControl("ddlEndTime")).SelectedItem.Text;
     bookingModeDetails.BookingDetails_EndTime = new TimeSpan(Convert.ToDateTime(endTime).Hour, Convert.ToDateTime(endTime).Minute, 0);
     string timeInterval = ((TextBox)row.FindControl("txtTimeInterval")).Text;
     if (!string.IsNullOrEmpty(timeInterval))
     {
         bookingModeDetails.BookingDetails_TimeInterval = Convert.ToInt32(((TextBox)row.FindControl("txtTimeInterval")).Text);
     }
     bookingModeDetails.BookingDetails_Trucks = Convert.ToInt32(((TextBox)row.FindControl("txtTruckLimit")).Text);
     return bookingModeDetails;
 }