コード例 #1
0
        // GET api/noticeboard
        public SocialNoticeBoard.Domain.DTO.dtoNoticeBoardPlainListResponse Get(
            [FromUri] DateTime referenceDateTime
            )
        {
            // Blocco da rendere "generico" su TUTTE le chiamate, esclusa login!!!
            dtoSocialDashboardPermissionResponse dpr = (dtoSocialDashboardPermissionResponse)CoreService.PermissionGet(
                COL_BusinessLogic_v2.UCServices.Services_SocialNoticeboard.Codex,
                UserContext.CurrentUserID,
                UserContext.CurrentCommunityID);

            dtoNoticeBoardPlainListResponse response = new dtoNoticeBoardPlainListResponse();

            response.ErrorInfo = base.LastError;

            if (!dpr.Admin && !dpr.View)
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.NoServicePermission;
            }

            dtoMessageListPlain list = Service.MessageGetListPlain_Update(base.UserContext.CurrentCommunityID, referenceDateTime);

            response.Messages          = list.Messages;
            response.ReferenceDateTime = list.ReferenceDateTime;
            //.(communityId);

            response.Success   = true;
            response.ErrorInfo = GenericError.None;

            //ActionFilters
            CheckResponse(response);

            return(response);
        }
コード例 #2
0
        // DELETE api/noticeboard/5
        public dtoCretePostResponse Delete([FromUri] int id)
        {
            dtoSocialDashboardPermissionResponse dpr = (dtoSocialDashboardPermissionResponse)CoreService.PermissionGet(
                COL_BusinessLogic_v2.UCServices.Services_SocialNoticeboard.Codex,
                UserContext.CurrentUserID,
                UserContext.CurrentCommunityID);

            dtoCretePostResponse response = new dtoCretePostResponse();

            response.ErrorInfo = base.LastError;

            if (!dpr.Admin && !dpr.Delete)
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.NoServicePermission;
            }
            if (id < 1)
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.InvalidDataInput;
            }

            if (id < 1 && (!dpr.Admin && !dpr.Delete))
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.InvalidDataInput;
            }

            if (response.ErrorInfo == GenericError.None)
            {
                response.Comment = Service.PostDelete(id);

                if (response.Comment != null && response.Comment.Id <= 0)
                {
                    response.ErrorInfo = GenericError.Internal;
                }
                else
                {
                    response.Success = true;
                }
            }

            //In ActionFilters
            CheckResponse(response);
            return(response);
        }
コード例 #3
0
        // Post api/esempio/
        /// <summary>
        /// Crea un nuovo messaggio nella bacheca social
        /// </summary>
        /// <param name="data">dtoCommentCreate</param>
        /// <returns>dtoCretePostResponse</returns>
        public dtoCretePostResponse Post(
            SocialNoticeBoard.Domain.DTO.dtoCommentCreate data)
        {
            // Blocco da rendere "generico" su TUTTE le chiamate, esclusa login!!!
            dtoSocialDashboardPermissionResponse dpr = (dtoSocialDashboardPermissionResponse)CoreService.PermissionGet(
                COL_BusinessLogic_v2.UCServices.Services_SocialNoticeboard.Codex,
                UserContext.CurrentUserID,
                UserContext.CurrentCommunityID);

            dtoCretePostResponse response = new dtoCretePostResponse();

            response.ErrorInfo = base.LastError;

            if (!dpr.Admin && !(dpr.Comment && data.ParentMessageId != null) && !(dpr.NewPost && data.ParentMessageId == null))
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.NoServicePermission;
            }



            if (data == null)
            {
                response.Success   = false;
                response.ErrorInfo = GenericError.InvalidDataInput;
            }

            if (response.ErrorInfo == GenericError.None)
            {
                response.Comment = Service.PostCreate(data);

                if (response.Comment != null && response.Comment.Id <= 0)
                {
                    response.ErrorInfo = GenericError.Internal;
                }
                else
                {
                    response.Success = true;
                }
            }

            //In ActionFilters
            CheckResponse(response);
            return(response);
        }