public async Task DeleteFaq(FaqDTO faq) { var deleteFaq = _mapper.Map <Faq>(faq); var accountType = await _accountRepo.GetAsync(deleteFaq.AccountTypeId); accountType.RemoveFaq(deleteFaq); await _accountRepo.SaveAsync(); }
public async Task <Faq> UpdateFaq(FaqDTO faq) { var accountType = await _accountRepo.GetAsync(faq.AccountTypeId); var updatedFaq = _mapper.Map <Faq>(faq); accountType.UpdateFaq(updatedFaq); await _accountRepo.SaveAsync(); return(updatedFaq); }
public async Task <Faq> SaveNewFaq(FaqDTO faq) { var accountType = await _accountRepo.GetAsync(faq.AccountTypeId); var newFaq = _mapper.Map <Faq>(faq); accountType.AddFaq(newFaq); await _accountRepo.SaveAsync(); return(newFaq); }
public async Task <IActionResult> DeleteFaq([FromQuery] FaqDTO faq) { try { await _appDataService.DeleteFaq(faq); await _logRepo.LogAsync(LogTypes.Delete, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Delete, "Delete FAQ", faq.Id)); await _logRepo.SaveAsync(); return(Ok()); } catch (Exception e) { await _logRepo.LogAsync(LogTypes.Error, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Error, e.Message, 0, e.StackTrace)); await _logRepo.SaveAsync(); ModelState.AddModelError("Exception", e.Message); return(BadRequest(ModelState)); } }
public async Task <IActionResult> SaveNewFaq(FaqDTO newFaq) { try { var savedFaq = await _appDataService.SaveNewFaq(newFaq); await _logRepo.LogAsync(LogTypes.Update, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Update, "Added FAQ", savedFaq.Id)); await _logRepo.SaveAsync(); return(Ok(savedFaq)); } catch (Exception e) { await _logRepo.LogAsync(LogTypes.Error, new LogEntry(GetCurrentUserId(), GetIpAddress(), (int)LogTypes.Error, e.Message, 0, e.StackTrace)); await _logRepo.SaveAsync(); ModelState.AddModelError("Exception", e.Message); return(BadRequest(ModelState)); } }