public ActionResult UpdateTestGroup(TestGroupDto testGroupDto) { if (testGroupDto != null) { try { var testGroupFromDb = testsService.GetTestGroup(testGroupDto.Id); if (testGroupFromDb != null) { var convertedTestGroup = testGroupDto.GetTestGroup(testGroupFromDb, testGroupDto); testsService.UpdateTestGroup(convertedTestGroup); } else { throw new Exception("The test group does not exist"); } } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while updating the test group")))); } return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS))); } else { return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper test group details")))); } }
public ActionResult AddNewTestGroup(TestGroupDto testGroupDto) { if (testGroupDto != null) { var testGroup = testGroupDto.GetTestGroup(testGroupDto); if (testGroup != null) { try { testsService.InsertTestGroup(testGroup); } catch (Exception e) { Program.Logger.Error(e); return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Error occurred while creating new group")))); } return(Ok(GetResponse(ResponseType.ACK, ResponseStatusCode.SUCCESS))); } else { return(Ok(GetResponse(ResponseType.FAIL, ResponseStatusCode.FAIL, GetError(ErrorCodes.dataNotFound, "Failed", "Something went wrong.")))); } } else { return(BadRequest(GetResponse(ResponseType.ERROR, ResponseStatusCode.ERROR, GetError(ErrorCodes.invalidData, "Invalid input", "Please enter proper group details")))); } }
public async Task <TestGroupDto> DeleteTestGroup(TestGroupDto responseModel) { var url = URLBuilder.GetURL(Controllers.TEST, EndPoint.TEST_GROUP_DELETE); return(await requestProvider.DeleteAsync(url, responseModel, new Dictionary <string, string> { ["id"] = responseModel.Id.ToString() })); }
public async Task <TestGroupDto> AddNewTestGroup(TestGroupDto testGroupDto) { var url = URLBuilder.GetURL(Controllers.TEST, EndPoint.TEST_GROUP_ADD); return(await requestProvider.PostAsync(url, testGroupDto)); }
public async Task <TestGroupDto> UpdateTestGroup(TestGroupDto testGroupDto) { var url = URLBuilder.GetURL(Controllers.TEST, EndPoint.TEST_GROUP_UPDATE); return(await requestProvider.PutAsync(url, testGroupDto)); }