Ejemplo n.º 1
0
        public static T GetControllerInstance <T>()
        {
            if (typeof(T) == typeof(IClipperUserAPI) ||
                typeof(IClipperSystemAdministratorAPI) == typeof(T) ||
                typeof(IClipperStaffChiefAPI) == typeof(T))
            {
                return((T)(object)new UserController());
            }

            if (typeof(T) == typeof(IClipperDatabase))
            {
                return((T)DatabaseAdapterFactory.GetControllerInstance <IClipperDatabase>());
            }

            if (typeof(T) == typeof(IClipperService))
            {
                return((T)(object)new StatusController());
            }

            if (typeof(T) == typeof(IClipperOrganizationalUnitAPI))
            {
                return((T)(object)new OrganizationalUnitController());
            }

            if (typeof(T) == typeof(ICrawlerController))
            {
                return((T)(object)CrawlerController.GetCrawlerController());
            }

            if (typeof(T) == typeof(INotificationController))
            {
                return((T)(object)new NotificationControllerWrapper());
            }

            throw new ArgumentOutOfRangeException(nameof(T));
        }
 /// <summary>
 /// Changes the source.
 /// </summary>
 /// <param name="user">The user.</param>
 /// <param name="updatedSource">The updated source.</param>
 /// <returns>MethodResult indicating success</returns>
 public MethodResult ChangeSource(User user, Source updatedSource)
 {
     Factory.GetControllerInstance <IClipperDatabase>().UpdateSource(updatedSource);
     CrawlerController.GetCrawlerController().Restart();
     return(new MethodResult());
 }
 /// <summary>
 /// Deletes the given source.
 /// </summary>
 /// <param name="user">The user who requests the deletion.</param>
 /// <param name="toDelete">The source to delete.</param>
 /// <returns>MethodResult indicating success</returns>
 public MethodResult DeleteSource(User user, Guid toDelete)
 {
     Factory.GetControllerInstance <IClipperDatabase>().DeleteSource(toDelete);
     CrawlerController.GetCrawlerController().Restart();
     return(new MethodResult());
 }
 /// <summary>
 /// Adds the given source.
 /// </summary>
 /// <param name="user">The user who requests the addition.</param>
 /// <param name="toAdd">The source to add.</param>
 /// <returns>MethodResult indicating success</returns>
 public MethodResult AddSource(User user, Source toAdd)
 {
     Factory.GetControllerInstance <IClipperDatabase>().AddSource(toAdd);
     CrawlerController.GetCrawlerController().Restart();
     return(new MethodResult());
 }