Example #1
0
        public HttpResponseMessage AddJob([FromBody] ReviewDto reviewDto)
        {
            return(HandleRequestSafely(() =>
            {
                if (reviewDto == null)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Body can't be null");
                }

                var review = new ReviewFactory().GetReview(reviewDto);
                review.Job = _jobService.GetById(review.Job.Id);
                if (review.Job == null)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Review doesn't exist");
                }

                if (review.Job.Asignee == null)
                {
                    return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Review must have an asignee");
                }

                if (review.Job.Review == null)
                {
                    _reviewService.Add(review);
                }
                else
                {
                    review.Id = review.Job.Review.Id;
                    _reviewService.Update(review);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }));
        }
Example #2
0
        protected void postBtn_Click(object sender, EventArgs e)
        {
            int id = Int32.Parse(Request.QueryString["id"].ToString());

            if (ratingTxt.Text == "")
            {
                errorLb.Text = "Rating Must be filled";
            }
            else if (Int32.Parse(ratingTxt.Text) < 1 || Int32.Parse(ratingTxt.Text) > 5)
            {
                errorLb.Text = "Rating must be between 1 to 5";
            }
            else if (reviewDescTxt.Text.Length > 255)
            {
                errorLb.Text = "Review Description maximal length is 255 characters";
            }
            else
            {
                string reviewDesc   = reviewDescTxt.Text;
                int    reviewRating = Int32.Parse(ratingTxt.Text);
                Member m            = (Member)Session["User"];
                Review r            = ReviewFactory.createReview(reviewRating, reviewDesc, id, m.MemberEmail);
                ReviewRepository.addProductReviewToDatabase(r);
                Response.Redirect("ProductDetail.aspx?id=" + id);
            }
        }
        public static bool InsertNewReview(int trDetailId, int rating, string desciption)
        {
            Review newReview = ReviewFactory.CreateReview(trDetailId, rating, desciption);

            if (newReview != null)
            {
                return(ReviewRepository.InsertNewReview(newReview));
            }
            return(false);
        }
Example #4
0
        public static Review GetById(int ReviewId)
        {
            string query = string.Format("SELECT * FROM [Review] WHERE (ReviewId) = {0}", ReviewId);

            DataTable dt = DatabaseConnection.ExecuteQuery(query);
            Review    u  = null;

            foreach (DataRow x in dt.Rows)
            {
                u = ReviewFactory.Create(Int32.Parse(x["ReviewRating"].ToString()),
                                         x["ReviewText"].ToString(),
                                         Int32.Parse(x["ProductId"].ToString()),
                                         Int32.Parse(x["UserId"].ToString()));
            }
            return(u);
        }
Example #5
0
        public static async Task MainAsync(Configuration configuration, CancellationToken cancel)
        {
            var persistence      = new JsonFileKeyValueStore(new FileInfo(configuration.Get("db-file-location")));
            var gamesPersistence = new JsonFileKeyValueStore(new FileInfo(configuration.Get("games-db-location")));

            var slackApi = new SlackApi(configuration.Get("slack-api-key"));

            var slackRtm = await(ReconnectingSlackRealTimeMessaging.CreateAsync(
                                     async() => await slackApi.StartRtm()));
            var aliasList = GetAliasList(slackRtm.InstanceInfo.Users);

            var commandParser = new SlackCommandParser("scbot", slackRtm.InstanceInfo.BotId);

            var webClient = new WebClient();

            var features = new FeatureMessageProcessor(commandParser,
                                                       NoteProcessor.Create(commandParser, persistence),
                                                       //ZendeskTicketTracker.Create(commandParser, persistence, configuration),
                                                       RecordReplayTraceManagement.Create(commandParser),
                                                       SeatingPlans.Create(commandParser, webClient),
                                                       Webcams.Create(commandParser, configuration),
                                                       Silly.Create(commandParser, webClient),
                                                       Installers.Create(commandParser, webClient),
                                                       Polls.Create(commandParser),
                                                       RollBuildNumbers.Create(commandParser, configuration),
                                                       ReviewFactory.Create(commandParser, webClient, configuration),
                                                       LabelPrinting.Create(commandParser, webClient, configuration),
                                                       Jira.Create(commandParser),
                                                       CompareTeamEmails.Create(commandParser, configuration),
                                                       GamesProcessor.Create(commandParser, gamesPersistence, aliasList)
                                                       );

            var pasteBin = new HasteServerPasteBin(webClient, configuration.Get("haste-server-url"));

            var newChannelNotificationsChannel = configuration.GetWithDefault("new-channels-notification-channel", null);
            var newChannelProcessor            = GetNewChannelProcessor(newChannelNotificationsChannel);

            var bot = new Bot(
                new ErrorReportingMessageProcessor(
                    new ConcattingMessageProcessor(features),
                    pasteBin),
                newChannelProcessor);

            var handler = new SlackMessageHandler(bot, slackRtm.InstanceInfo.BotId);

            MainLoop(slackRtm, handler, slackApi, cancel);
        }
Example #6
0
 public static void Insert(int ReviewRating, string ReviewText, int ProductId, int UserId)
 {
     Review u = ReviewFactory.Create(ReviewRating, ReviewText, ProductId, UserId); ReviewRepository.Insert(u);
 }                                                                                                                              // Register
 public void Setup()
 {
     _factory = new ReviewFactory();
 }