Beispiel #1
0
        public HttpResponseMessage RemoveLevel([FromBody] DeleteLevelFormModel levelData)
        {
            try
            {
                if (levelData == null || !levelData.Level_Id.HasValue)
                {
                    return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ErrorMessages.ERR_NO_LEVEL_ID));
                }

                SessionInstance mySession = SessionManager.Instance.GetSessionByToken(levelData.Token);
                if (mySession == null)
                {
                    return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ErrorMessages.ERR_NOT_LOGGED_IN));
                }

                if (mySession.AccounData.Group < UserGroup.MODERATOR)
                {
                    return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ErrorMessages.ERR_NO_RIGHTS));
                }

                this.levelsDAL.UnpublishLevel(levelData.Level_Id.Value);

                return(HttpResponseFactory.Response200Plain(StatusKeys.SUCCESS, StatusMessages.TRUE));
            }
            catch (PR2Exception ex)
            {
                return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ex.Message));
            }
            catch (Exception ex)
            {
                return(HttpResponseFactory.Response500Plain(ex.Message));
            }
        }
Beispiel #2
0
        public HttpResponseMessage DeleteLevel([FromBody] DeleteLevelFormModel levelData)
        {
            try
            {
                if (levelData == null || !levelData.Level_Id.HasValue)
                {
                    return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ErrorMessages.ERR_NO_FORM_DATA));
                }

                SessionInstance mySession = SessionManager.Instance.GetSessionByToken(levelData.Token);
                if (mySession == null)
                {
                    return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ErrorMessages.ERR_NOT_LOGGED_IN));
                }

                this.levelsDAL.SoftDeleteLevel(mySession.AccounData.UserId, levelData.Level_Id.Value);

                return(HttpResponseFactory.Response200Plain(StatusKeys.SUCCESS, StatusMessages.TRUE));
            }
            catch (PR2Exception ex)
            {
                return(HttpResponseFactory.Response200Plain(StatusKeys.ERROR, ex.Message));
            }
            catch (Exception ex)
            {
                return(HttpResponseFactory.Response500Plain(ex.Message));
            }
        }