public RoomController(
     IRoomService roomService,
     IResponseModel responseModel)
 {
     _roomService   = roomService;
     _responseModel = responseModel;
 }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        public IActionResult CreateResultFromResponseModel(IResponseModel response)
        {
            switch (response.StatusCode)
            {
            case HttpStatusCode.Accepted:
                return(Accepted(response));

            case HttpStatusCode.NotFound:
                return(NotFound(response));

            case HttpStatusCode.BadRequest:
                return(BadRequest(response));

            case HttpStatusCode.OK:
                return(Json(response));

            case HttpStatusCode.Created:
            {
                var url = ControllerContext?
                          .HttpContext?
                          .Request?
                          .GetDisplayUrl();

                return(Created(url ?? "", response));
            }

            default:
                return(StatusCode((int)response.StatusCode, response));
            }
        }
Beispiel #3
0
 public TransactionController(
     ITransactionService transactionService,
     IResponseModel responseModel)
 {
     _transactionService = transactionService;
     _responseModel      = responseModel;
 }
Beispiel #4
0
 public ProductController(
     IProductService productService,
     IResponseModel response)
 {
     _productService = productService;
     _response       = response;
 }
Beispiel #5
0
        public void ProcessResponse(IResponseModel responseModel)
        {
            WriteOutput(responseModel);

            if (responseModel.ShouldCrawl)
                CrawlForLinksInResponse(responseModel);
        }
Beispiel #6
0
 public CategoryRepository(
     DatabaseContext db,
     IResponseModel response)
 {
     _db       = db;
     _response = response;
 }
 public CategoryController(
     ICategoryService categoryService,
     IResponseModel response)
 {
     _categoryService = categoryService;
     _response        = response;
 }
Beispiel #8
0
 public AccountController(
     IAccountService accountService,
     IResponseModel responseModel)
 {
     _acctService   = accountService;
     _responseModel = responseModel;
 }
 public ProductRepository(
     DatabaseContext db,
     IResponseModel response)
 {
     _db       = db;
     _response = response;
 }
Beispiel #10
0
 public PropertyController(
     IPropertyService propertyService,
     IResponseModel responseModel)
 {
     _propertyService = propertyService;
     _responseModel   = responseModel;
 }
Beispiel #11
0
        public void NotifySlack(IResponseModel responseModel)
        {
            if (!HasWebHookUrl)
            {
                return;
            }

            var message = string.Format(MessageFormat, responseModel.RequestedUrl, responseModel.StatusCodeNumber, responseModel.ReferrerUrl);

            var client  = new RestClient(WebHookUrl);
            var request = new RestRequest(Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddBody(
                new
            {
                text       = message,
                username   = BotName,
                icon_emoji = BotIcon,
                mrkdwn     = true
            });

            client.ExecuteAsync(request, null);
        }
Beispiel #12
0
 public MemberController(
     IMemberService memberService,
     IResponseModel response)
 {
     _memberService = memberService;
     _response      = response;
 }
Beispiel #13
0
 public RenterController(
     IRenterService renterService,
     IResponseModel responseModel)
 {
     _renterService = renterService;
     _responseModel = responseModel;
 }
Beispiel #14
0
 public void Assign(IResponseModel model)
 {
     UId = model.UId;
     //Total = model.Total;
     Message = model.Message;
     Errors  = model.Errors;
     Params  = model.Params;
 }
Beispiel #15
0
 public TasksController(
     ITasksService tasksService,
     ICommentService commentService,
     IResponseModel response)
 {
     _tasksService   = tasksService;
     _commentService = commentService;
     _response       = response;
 }
Beispiel #16
0
        public void ProcessResponse(IResponseModel responseModel)
        {
            WriteOutput(responseModel);

            if (responseModel.ShouldCrawl)
            {
                CrawlForLinksInResponse(responseModel);
            }
        }
Beispiel #17
0
 private void Write(IResponseModel responseModel)
 {
     _writer?.WriteLine("{1}{0}{2}{0}{3}{0}{4}",
         _settings.CsvDelimiter,
         responseModel.StatusCodeNumber,
         responseModel.StatusCode,
         responseModel.RequestedUrl,
         responseModel.ReferrerUrl);
 }
 private void UpdateStatus(IResponseModel responseModel)
 {
     lock (UrlList)
     {
         // First set the status code for the completed link (this will set "CheckingFinished" to true)
         LinkModel lm = UrlList.Where(l => l.Address == responseModel.RequestedUrl).First();
         lm.StatusCode = responseModel.StatusCodeNumber;
     }
 }
Beispiel #19
0
        public static IActionResult ToHttpResponse(this IResponseModel response)
        {
            var status = response.DidError ? HttpStatusCode.InternalServerError : HttpStatusCode.OK;

            return(new ObjectResult(response)
            {
                StatusCode = (int)status
            });
        }
Beispiel #20
0
 private void Write(IResponseModel responseModel)
 {
     _writer?.WriteLine("{1}{0}{2}{0}{3}{0}{4}",
                        _settings.CsvDelimiter,
                        responseModel.StatusCodeNumber,
                        responseModel.StatusCode,
                        responseModel.RequestedUrl,
                        responseModel.ReferrerUrl);
 }
Beispiel #21
0
 public MemberService(
     DatabaseContext db,
     IResponseModel response,
     IRepository repo)
 {
     _db       = db;
     _response = response;
     _repo     = repo;
 }
Beispiel #22
0
 public Service(
     IMoney2WordConvertor money2WordConvertor,
     INameValidator nameValidator,
     IResponseModel responseModel)
 {
     this.money2WordConvertor = money2WordConvertor;
     this.responseModel       = responseModel;
     this.nameValidator       = nameValidator;
 }
Beispiel #23
0
 public AccountService(
     DatabaseContext db,
     IConfiguration config,
     IResponseModel response)
 {
     _db       = db;
     _config   = config;
     _response = response;
 }
 public AccountService(
     IUserRepository userRepo,
     IConfiguration config,
     IResponseModel response)
 {
     _userRepo = userRepo;
     _config   = config;
     _response = response;
 }
 public void WriteError(IResponseModel responseModel)
 {
     foreach (string line in new string[] { responseModel.ToString() })
     {
         Thread.Sleep(MSSLEEPBEFORESIGNALRMSG);
         _clientProxy.SendAsync("failedurlmessage", line);
     }
     WriteInfo(new string[] { responseModel.ToString() });
 }
Beispiel #26
0
 private IActionResult Response <T>(IResponseModel <T> result) where T : class
 {
     return(result switch
     {
         SuccessResponse <T> _ => Ok(result),
         NotFoundResponse <T> _ => NotFound(result),
         BadRequestResponse <T> _ => BadRequest(result),
         InternalError <T> _ => StatusCode(500, result),
         _ => NotFound()
     });
 public ProjectService(
     DatabaseContext db,
     IResponseModel response,
     IRepository repo,
     ILoggerService loggerService)
 {
     _db            = db;
     _response      = response;
     _repo          = repo;
     _loggerService = loggerService;
 }
 public TransactionService(
     DatabaseContext db,
     IConfiguration config,
     IResponseModel response,
     ILoggerService loggerService)
 {
     _db            = db;
     _config        = config;
     _response      = response;
     _loggerService = loggerService;
 }
        public bool AddTaskForUser(int userId, string description, IResponseModel model)
        {
            string message = GetMessageForModel(userId, description);

            if (message != null)
            {
                model.AddAttribute("action_result", message);
                return(false);
            }

            return(true);
        }
 public RoomService(
     DatabaseContext db,
     IRepository repo,
     IConfiguration config,
     IResponseModel response,
     ILoggerService loggerService)
 {
     _db            = db;
     _repo          = repo;
     _config        = config;
     _response      = response;
     _loggerService = loggerService;
 }
 public bool AddTaskForUser(int userId, string description, IResponseModel model)
 {
     try
     {
         _taskService.AddTaskForUser(userId, new UserTask(description));
     }
     catch (AddUserTaskException e)
     {
         model.AddAttribute("action_result", DataProvider.GetErrorMessage(e));
         return(false);
     }
     return(true);
 }
Beispiel #32
0
        public void CrawlForLinksInResponse(IResponseModel responseModel)
        {
            var linksFoundInMarkup = MarkupHelpers.GetValidUrlListFromMarkup(responseModel.Markup, ValidUrlParser, CheckImages);

            foreach (var url in linksFoundInMarkup)
            {
                if (VisitedUrlList.Contains(url))
                    continue;

                VisitedUrlList.Add(url);
                SendRequest(url, responseModel.RequestedUrl);
            }
        }
Beispiel #33
0
 public void Merge(IResponseModel model, FollowUpModel followUp, RepromptModel reprompt, MediaResponseModel mediaResponse)
 {
     Content              = Content ?? model.Content;
     SmallImage           = SmallImage ?? model.SmallImage;
     LargeImage           = LargeImage ?? model.LargeImage;
     BackgroundImage      = BackgroundImage ?? model.BackgroundImage;
     Audio                = Audio ?? model.Audio;
     Video                = Video ?? model.Video;
     DisplayTextOverride  = DisplayTextOverride ?? model.DisplayTextOverride;
     DisplayTitleOverride = DisplayTitleOverride ?? model.DisplayTitleOverride;
     FollowUp             = FollowUp ?? followUp;
     Reprompt             = Reprompt ?? reprompt;
     MediaResponse        = MediaResponse ?? mediaResponse;
 }
Beispiel #34
0
 public void WriteOutput(IResponseModel responseModel)
 {
     if (!responseModel.IsSuccess)
     {
         foreach (var output in Outputs)
         {
             output.WriteError(responseModel);
         }
     }
     else if (!OnlyReportBrokenLinksToOutput)
     {
         foreach (var output in Outputs)
         {
             output.WriteInfo(responseModel);
         }
     }
 }
Beispiel #35
0
        public void NotifySlack(IResponseModel responseModel)
        {
            if (!HasWebHookUrl)
                return;

            var message = string.Format(MessageFormat, responseModel.RequestedUrl, responseModel.StatusCodeNumber, responseModel.ReferrerUrl);

            var client = new RestClient(WebHookUrl);
            var request = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json };
            request.AddBody(
                new
                {
                    text = message,
                    username = BotName,
                    icon_emoji = BotIcon,
                    mrkdwn = true
                });

            client.ExecuteAsync(request, null);
        }
Beispiel #36
0
 public void WriteError(IResponseModel responseModel)
 {
     _slackClient.NotifySlack(responseModel);
 }
Beispiel #37
0
 public void WriteInfo(IResponseModel responseModel)
 {
     // Write nothing to Slack
 }
Beispiel #38
0
 public void WriteInfo(IResponseModel responseModel)
 {
     Write(responseModel);
 }
Beispiel #39
0
 public void WriteInfo(IResponseModel responseModel)
 {
     Console.WriteLine(responseModel.ToString());
 }
Beispiel #40
0
 public void WriteError(IResponseModel responseModel)
 {
     ConsoleHelper.WriteError(responseModel.ToString());
 }
Beispiel #41
0
 public void WriteError(IResponseModel responseModel)
 {
     Write(responseModel);
 }