예제 #1
0
        public ActionResult <int> DeleteTagById(int tagId)
        {
            AuthorDataAccess tags = new AuthorDataAccess();
            var tag = tags.GetTagById(tagId);

            if (tag == null)
            {
                return(BadRequest("Тега не существует"));
            }
            tags.DeleteTagById(tagId);
            return(Ok(tagId));
        }
예제 #2
0
        public ActionResult <int> PutTagById([FromBody] TagInputModel tagModel)
        {
            Mapper           mapper = new Mapper();
            TagDTO           tagDto = mapper.ConvertTagInputModelToTagDTO(tagModel);
            AuthorDataAccess tags   = new AuthorDataAccess();
            var tag = tags.GetTagById(tagModel.ID);

            if (tag == null)
            {
                return(BadRequest("Тега не существует"));
            }
            if (string.IsNullOrWhiteSpace(tagModel.Name))
            {
                return(BadRequest("Введите название тега"));
            }
            tags.UpdateTagById(tagDto);
            return(Ok(tagModel.ID));
        }
예제 #3
0
        public ActionResult <int> PostTagInTest(TestTagInputModel testTagModel)
        {
            Mapper           mapper     = new Mapper();
            TestTagDTO       testTagDto = mapper.ConvertTestTagInputModelToTestTagDTO(testTagModel);
            AuthorDataAccess tags       = new AuthorDataAccess();
            var test = tags.GetTestById(testTagModel.TestID);

            if (test == null)
            {
                return(BadRequest("Теста не существует"));
            }
            var tag = tags.GetTagById(testTagModel.TagID);

            if (tag == null)
            {
                return(BadRequest("Тега не существует"));
            }
            return(Ok(tags.TestTagCreate(testTagDto)));
        }
예제 #4
0
        public ActionResult <int> DeleteTagFromTest(TestTagInputModel testTagModel)
        {
            AuthorDataAccess tags = new AuthorDataAccess();
            var test = tags.GetTestById(testTagModel.TestID);

            if (test == null)
            {
                return(BadRequest("Теста не существует"));
            }
            var tag = tags.GetTagById(testTagModel.TagID);

            if (tag == null)
            {
                return(BadRequest("Тега не существует"));
            }
            var testTag = tags.GetTestByTag(testTagModel.TestID, testTagModel.TagID);

            if (testTag == null)
            {
                return(BadRequest("У данного теста нет такого тега"));
            }
            tags.DeleteByTestIdTagId(testTagModel.TestID, testTagModel.TagID);
            return(Ok("Успешно удалено!"));
        }