public ActionResult InsertDriverInfo([FromBody] DriverInfo data, string username)
 {
     try
     {
         if (data != null && username != null)
         {
             var checkDriver = MH.GetSingleObject(driverinfo_collection, "DriverName", data.DriverName, "Address", data.Address).Result;
             if (checkDriver != null)
             {
                 return(BadRequest(new ResponseData
                 {
                     Code = "401",
                     Message = "Driver with same driver name and address is already added"
                 }));
             }
             else
             {
                 #region Calculate driver id
                 var getDrivers = MH.GetListOfObjects(driverinfo_collection, null, null, null, null).Result;
                 if (getDrivers.Count == 0)
                 {
                     data.DriverId = "DR-1";
                 }
                 else
                 {
                     List <long> idList = new List <long>();
                     foreach (var driver in getDrivers)
                     {
                         DriverInfo driverInfo  = BsonSerializer.Deserialize <DriverInfo>(driver);
                         long       seperatedId = Convert.ToInt64(driverInfo.DriverId.Substring(driverInfo.DriverId.LastIndexOf('-') + 1));
                         idList.Add(seperatedId);
                     }
                     var maxId = idList.Max();
                     data.DriverId = "DR-" + (maxId + 1);
                 }
                 #endregion
                 data.IsActive = true;
                 var insert = MH.InsertNewDriverInfo(data, driverinfoCollection);
                 if (insert == true)
                 {
                     AL.CreateLog(username, "InsertDriverInfo", null, data, activitylog_collection);
                     return(Ok(new ResponseData
                     {
                         Code = "200",
                         Message = "Inserted",
                         Data = data
                     }));
                 }
                 else
                 {
                     return(BadRequest(new ResponseData
                     {
                         Code = "402",
                         Message = "Driver info with same id is already added"
                     }));
                 }
             }
         }
         else
         {
             return(BadRequest(new ResponseData
             {
                 Code = "403",
                 Message = "Bad Request"
             }));
         }
     }
     catch (Exception ex)
     {
         SL.CreateLog("DriverController", "InsertDriverInfo", ex.Message);
         return(BadRequest(new ResponseData
         {
             Code = "400",
             Message = "Failed",
             Data = ex.Message
         }));
     }
 }