/// <summary> /// Updates the asset. /// </summary> /// <param name="asset">The asset.</param> /// <returns></returns> public void UpdateAsset(AssetViewModel assetViewModel) { try { Asset asset = AssetViewModelFactory.CreateFromViewModelModel(assetViewModel, ObjectMapper); AssetManager.Update(asset); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } }
/// <summary> /// Gets the asset by name. /// </summary> /// <param name="id">The asset name.</param> public AssetViewModel GetAssetByName(string assetName, bool includeTags = false) { try { Asset asset = AssetManager.GetAssetByName(assetName); return(AssetViewModelFactory.CreateFromDomainModel(asset, ObjectMapper)); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(null); }
/// <summary> /// Gets the asset by id. /// </summary> /// <param name="id">The id.</param> /// /// <summary> /// Gets the asset by id. /// </summary> /// <param name="id">The id.</param> public AssetViewModel GetAssetById(int id, bool includeTags = false) { try { Asset asset = includeTags ? AssetManager.FindWithTagsBy(id) : AssetManager.FindBy(id); return(AssetViewModelFactory.CreateFromDomainModel(asset, ObjectMapper)); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(null); }
/// <summary> /// Gets the document assets by company. /// </summary> /// <param name="companyId">The company id.</param> /// <returns></returns> public List <AssetViewModel> GetDocumentAssetsByCompany(int companyId) { List <AssetViewModel> models = new List <AssetViewModel>(); try { List <Asset> assets = AssetManager.GetDocumentAssetsByCompany(companyId); models = AssetViewModelFactory.CreateFromDomainModel(assets, ObjectMapper); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } return(models); }
/// <summary> /// Creates the asset. /// </summary> /// <param name="assetViewModel">The asset view model.</param> public void CreateAsset(CreateAssetViewModel createAssetViewModel, string uploadPath, int companyId) { try { AssetViewModel assetviewModel = AssetViewModelFactory.CreateAssetViewModelFromCreateAssetViewModel(createAssetViewModel, uploadPath, companyId, FileManager); if (assetviewModel.AssetType == 1) { if (IsYoutubeVideo(assetviewModel)) { assetviewModel = embedYoutubeVideo(assetviewModel); } } Asset asset = AssetViewModelFactory.CreateFromViewModelModel(assetviewModel, ObjectMapper); AssetManager.Add(asset); } catch (Exception ex) { ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing); } }