Exemple #1
0
        public async Task <Result <CourseBookmark> > DeleteAsync(CourseBookmark bookmark)
        {
            var bookmarkDb = _mapper.Map <CourseBookmark, CourseBookmarkDb>(bookmark);
            var result     = await _bookmarkServiceDb.DeleteAsync(bookmarkDb);

            return(result.IsSuccess ? Result <CourseBookmark> .Ok(_mapper.Map <CourseBookmark>(result.Data))
                : (Result <CourseBookmark>)Result.Fail(result.Message));
        }
Exemple #2
0
        public async Task <Result <CourseBookmark> > AddAsync(CourseBookmark bookmark)
        {
            bookmark.Id = Guid.NewGuid().ToString();
            var bookmarkDb = _mapper.Map <CourseBookmark, CourseBookmarkDb>(bookmark);
            var result     = await _bookmarkServiceDb.AddAsync(bookmarkDb);

            return(result.IsSuccess ? Result <CourseBookmark> .Ok(_mapper.Map <CourseBookmark>(result.Data))
                : (Result <CourseBookmark>)Result.Fail(result.Message));
        }
        public async Task <IHttpActionResult> Delete(CourseBookmark bookmark)
        {
            if (bookmark == null)
            {
                return(BadRequest());
            }

            var result = await _courseBookmarkService.DeleteAsync(bookmark);

            return(result.IsSuccess ? (IHttpActionResult)Ok(result.Data) : BadRequest(result.Message));
        }
        public async Task <IHttpActionResult> Add([FromBody, CustomizeValidator(RuleSet = "*")] CourseBookmark courseBookmark)
        {
            if (courseBookmark == null)
            {
                return(BadRequest());
            }

            var result = await _courseBookmarkService.AddAsync(courseBookmark);

            return(result.IsSuccess ? (IHttpActionResult)Ok(result.Data) : BadRequest(result.Message));
        }
Exemple #5
0
 public static CourseBookmark Add(CourseBookmark coursebookmark)
 {
     coursebookmark.Id = Guid.NewGuid().ToString();
     _coursebookmark.Add(coursebookmark);
     return(coursebookmark);
 }