public async Task <bool> ApproveBookMarkCard(BookmarkCard card) { try { var resultCard = await _db.BookMarkCards.FindAsync(card.BookmarkId); if (resultCard != null) { resultCard.IsCardValidationRequired = false; _db.BookMarkCards.Update(resultCard); // persist changes in the DB await _db.SaveChangesAsync(); return(true); } return(false); } catch (Exception ex) { Log.Error("An error occurred while saving the new bookmark card {Error} {StackTrace} {InnerException} {Source}", ex.Message, ex.StackTrace, ex.InnerException, ex.Source); } return(false); }
public async Task <IActionResult> AddBookMark([FromBody] BookmarkCard model) { bool result = await _bookmarkCardSvc.CreateBookMarkCard(model); if (result) { return(Ok(new { Message = "Card Successfully!" })); } return(BadRequest(new { Message = "Issue in Saving the card." })); }
public async Task <IActionResult> Approve([FromBody] BookmarkCard model) { bool result = await _bookmarkCardSvc.ApproveBookMarkCard(model); if (result) { return(Ok(new { Message = "Card Approved" })); } return(BadRequest(new { Message = "Card couldn't be approved" })); }
public async Task <bool> CreateBookMarkCard(BookmarkCard bookmarkCard) { try { var user = await _userManager.FindByNameAsync(bookmarkCard.UserName); bookmarkCard.IsCardValidationRequired = !user.isAdmin; //if admin card needs no validation, if user then it needs validation bookmarkCard.IsCardExpired = false; bookmarkCard.shortUrl = GetShorturl(bookmarkCard.LongUrl); await _db.BookMarkCards.AddAsync(bookmarkCard); // persist changes in the DB await _db.SaveChangesAsync(); return(true); } catch (Exception ex) { Log.Error("An error occurred while saving the new bookmark card {Error} {StackTrace} {InnerException} {Source}", ex.Message, ex.StackTrace, ex.InnerException, ex.Source); } return(false); }