public void Setup() { // Mock _configuration = new Mock <IConfiguration>(MockBehavior.Loose); _filingRepo = new Mock <IFilingRepo>(MockBehavior.Loose); _logger = new Mock <ILogger <FilingController> >(MockBehavior.Loose); // Mapper var config = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperConfig()); }); _mapper = new Mapper(config); // Config Filler <Filing> pFiller = new Filler <Filing>(); Filler <FilingDTO> pFillerDTO = new Filler <FilingDTO>(); filing = pFiller.Create(); filingDTO = pFillerDTO.Create(); // Service under test _filingController = new FilingController(_configuration.Object, _mapper, _filingRepo.Object, _logger.Object); }
public async Task <IActionResult> CreateFiling(FilingDTO data) { using var filingService = new ClientBase <FilingDTO>(_conectionString); var dataResult = await filingService.CreateData("/Filing/Create/", data); return(Json(dataResult)); }
public ActionResult Create(FilingDTO filing) { MethodBase method = MethodBase.GetCurrentMethod(); try { Filing newAction = Mapper.Map <Filing>(filing); newAction.IsValid = true; newAction.Id = 0; var response = FilingRepo.Create(newAction); if (response > 0) { CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information); return(Ok(response)); } else { CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Warning); return(BadRequest(response)); } } catch (Exception ex) { return(HandleError(ex.Message, GetMethodCode(method))); } }
public ActionResult Delete(FilingDTO filing) { MethodBase method = MethodBase.GetCurrentMethod(); try { if (filing.Id > 0) { Filing delAction = Mapper.Map <Filing>(filing); FilingRepo.Delete(delAction); CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information); return(Ok(true)); } else { CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Information); return(BadRequest()); } } catch (Exception ex) { return(HandleError(ex.Message, GetMethodCode(method))); } }