/// <summary> /// Converts the ListingType ViewModel into a ListingType Model to be used with the service. /// </summary> /// <param name="listingType">ViewModel to convert.</param> /// <returns>ListingTypeReturns null if parameter is null. Otherwise, returns Model to be used with the service.</returns> public static SP.ListingTypeSvc.ListingType ToModel(this VM.ListingTypeViewModel listingType) { if (null == listingType) { return null; } SP.ListingTypeSvc.ListingType result = new SP.ListingTypeSvc.ListingType() { ListingTypeGuid = listingType.ListingTypeGuid, ListingTypeName = listingType.ListingTypeName, }; return result; }
public static int InsertListingType(string listingTypeName) { try { // Create the service proxy object and populate it. SP.ListingTypeSvc.ListingType request = new SP.ListingTypeSvc.ListingType(); request.ListingTypeGuid = Guid.Empty; request.ListingTypeName = listingTypeName; // Call the service insert method. _listingTypeClient.InsertListingType(request); return 1; } catch (System.ServiceModel.FaultException ex) { throw ex; } catch (Exception ex) { throw ex; } }