/// <summary> /// Add Vehicle /// </summary> private Entities.FacadeResult AddVehicle() { Facade.IVehicle facResource = new Facade.Resource(); string userName = ((Entities.CustomPrincipal)Page.User).UserName; Entities.FacadeResult retval; try { retval = facResource.Create(vehicle, userName); } catch (BusinessFacadeException ex) { if (ex.InnerException is BusinessFacadeException && ex.InnerException.InnerException is BusinessLayerException && ex.InnerException.InnerException.InnerException is ThirdPartyTelematicsException) { return(new Entities.FacadeResult(false, "There was an error updating the vehicle on a third party telematics system. It may not be usable, please contact support.")); } else { throw; } } if (retval.Success) { // Store the new id in the viewstate m_resourceId = retval.ObjectId; vehicle.ResourceId = m_resourceId; ViewState[C_RESOURCE_ID] = m_resourceId; if (!string.IsNullOrEmpty(Configuration.BlueSphereCustomerId)) { try { var message = MobileWorkerFlow.MWFServicesCommunication.Client.AddNewVehicleToBlueSphere(vehicle, retval.ObjectId.ToString()); if (!string.IsNullOrEmpty(message)) { ViewState["IsUpdate"] = m_isUpdate = true; LoadVehicle(); return(new Entities.FacadeResult(false, "There was an error setting up the Vehicle for MWF, " + message)); } } catch { // MM (2nd April 2012): Not ideal but solution for now, if fail to get through to bluesphere then show error to user ViewState["IsUpdate"] = m_isUpdate = true; LoadVehicle(); retval = new Entities.FacadeResult(false, "There was an error adding the vehicle and they will not be usable, please contact support."); } } } else { return(new Entities.FacadeResult(false)); } return(retval); }