/// <summary> /// Returns a Service Package for the option if it exists or creates a new one for it and it's id /// </summary> /// <param name="performingUserId"></param> /// <param name="portfolioService"></param> /// <param name="optionId"></param> /// <param name="action">Add or Remove</param> /// <returns></returns> public static IServiceRequestPackageDto GetPackage(int performingUserId, IPortfolioService portfolioService, int optionId, ServiceRequestAction action) { IServiceRequestPackageDto package = null; try { package = portfolioService.GetServiceRequestPackagesForServiceOption(performingUserId, optionId, action).FirstOrDefault(); } catch (Exception) { /* situation is dealt with below */ } return(package); }
public static ServiceRequestPackage MapDtoToServiceRequestPackage(IServiceRequestPackageDto src) { if (src == null) { return(null); } return(new ServiceRequestPackage { Id = src.Id, Action = src.Action, Name = src.Name }); }
/// <summary> /// Make a default package when none exists /// </summary> /// <param name="performingUserId"></param> /// <param name="portfolioService"></param> /// <param name="optionId"></param> /// <returns></returns> public static IServiceRequestPackageDto GetPackage(int performingUserId, IPortfolioService portfolioService, int optionId) { IServiceRequestPackageDto package = null; package = new ServiceRequestPackageDto(); package.ServiceOptionCategoryTags = new List <IServiceOptionCategoryTagDto>(); //it consists of just the option category int categoryId = portfolioService.GetServiceOption(performingUserId, optionId).ServiceOptionCategoryId; package.ServiceOptionCategoryTags.Add( new ServiceOptionCategoryTagDto { ServiceOptionCategory = portfolioService.GetServiceOptionCategory(performingUserId, categoryId), ServiceOptionCategoryId = categoryId }); package.Name = package.ServiceOptionCategoryTags.First().ServiceOptionCategory.Name; return(package); }
/// <summary> /// Modifies the service Package in the database /// </summary> /// <param name="performingUserId"></param> /// <param name="servicePackage"></param> /// <param name="modification">Type of modification to make</param> /// <returns>Modified Service Request Package</returns> public IServiceRequestPackageDto ModifyServiceRequestPackage(int performingUserId, IServiceRequestPackageDto servicePackage, EntityModification modification) { return(_serviceRequestPackageController.ModifyServiceRequestPackage(performingUserId, servicePackage, modification)); }