public int InsertFollow(FollowersRequestModel model)
        {
            int uid = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Followers_Insert"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@FollowerId", UserService.GetCurrentUserId());
                paramCollection.AddWithValue("@FollowedId", model.FollowedId);


                SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                p.Direction    = System.Data.ParameterDirection.Output;
                paramCollection.Add(p);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                int.TryParse(param["@Id"].Value.ToString(), out uid);
            });

            SystemEventRequestModel se = new SystemEventRequestModel();

            se.ActorUserId  = UserService.GetCurrentUserId();
            se.EventType    = Enums.SystemEventType.Followed;
            se.TargetUserId = model.FollowedId.ToString();
            _SystemEventService.Insert(se);

            return(uid);
        }
        public async Task <ActionResult> CreateOrUpdateSystemEvent([FromForm] SystemEventRequestModel request, CancellationToken cancellationToken)
        {
            if (request == null)
            {
                return(BadRequest($"`{nameof(request)}` can not be null"));
            }

            if (string.IsNullOrWhiteSpace(request.text))
            {
                return(BadRequest($"{nameof(request.text)} can not be null or whitespace"));
            }

            var command = GetSlackCommand(request.text);

            if (command == null)
            {
                throw new ArgumentException($"Unrecognized command {request.text}");
            }

            switch (command.Item1)
            {
            case SlackCommand.Create:
                var categories = await _systemEventClient.CategoryAllGetAsync();

                var view = _slackModalTemplateBuilder.GetDialogTemplateWithCategories(
                    categories.Where(c => c.Name != "*" && c.SlackApp).ToList());

                var response = await _slackApiService.OpenDialogAsync(new OpenSlackModalRequest
                {
                    trigger_id = request.trigger_id,
                    view       = view
                });

                break;

            case SlackCommand.End:
                await _systemEventClient.EventEndPostAsync(command.Item2);

                break;

            default:
                throw new ArgumentException($"Unrecognized command {request.text}");
            }

            return(Ok());
        }
Exemple #3
0
        public int Insert(BlogsManageRequest model)
        {
            int uid = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Blogs_Insert2"
                                         , inputParamMapper : delegate(SqlParameterCollection paramCollection)
            {
                paramCollection.AddWithValue("@Title", model.Title);
                paramCollection.AddWithValue("@PublishDate", model.PublishDate);
                paramCollection.AddWithValue("@Category", model.Category);
                paramCollection.AddWithValue("@Slug", model.Slug);
                //paramCollection.AddWithValue("@UserId", model.UserId);
                paramCollection.AddWithValue("@UserId", UserService.GetCurrentUserId());
                paramCollection.AddWithValue("@PageContent", model.PageContent);
                paramCollection.AddWithValue("@IsFeatured", model.IsFeatured);
                paramCollection.AddWithValue("@WebsiteId", model.WebsiteId);


                SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                p.Direction    = System.Data.ParameterDirection.Output;

                paramCollection.Add(p);
            }, returnParameters : delegate(SqlParameterCollection param)
            {
                int.TryParse(param["@Id"].Value.ToString(), out uid);
            }
                                         );

            SystemEventRequestModel se = new SystemEventRequestModel();

            se.TargetID    = uid;
            se.ActorUserId = UserService.GetCurrentUserId();
            se.EventType   = Enums.SystemEventType.NewBlog;
            _SystemEventService.Insert(se);

            return(uid);
        }