public IHttpActionResult Add([FromBody] CopyTestDataModel copyTestDataModel) { var result = new ResultMessage <IEnumerable <TblTestDataDto> >(); try { result = this.testDataService.CopyTestData(this.UserId, copyTestDataModel); } catch (Exception ex) { this.LoggerService.LogException(ex); result.Messages.Add(new Message(null, ex.Message)); } return(this.CreateCustomResponse(result)); }
public IHttpActionResult Add([FromBody] CopyTestDataModel copyTestDataModel) { var result = new ResultMessage <bool>(); try { bool executionStatus = this.testDataService.CopyTestData(this.UserId, copyTestDataModel); if (executionStatus) { result.Item = true; } } catch (Exception ex) { this.LoggerService.LogException(ex); result.Messages.Add(new Message(null, ex.Message)); } return(this.CreateCustomResponse(result)); }
/// <summary> /// Copy the test steps from one test to another /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="copyTestDataModel">copyTestDataModel Object</param> /// <returns> /// TblTestDataDto List object /// </returns> public bool CopyTestData(long userId, CopyTestDataModel copyTestDataModel) { var result = new ResultMessage <IEnumerable <TblTestDataDto> >(); Dictionary <string, object> dictionary = new Dictionary <string, object> { { "fromtestid", copyTestDataModel.FromTestId }, { "totestid", copyTestDataModel.ToTestId }, { "createdby", userId } }; if (copyTestDataModel.CopyAll) { dictionary.Add("testdataids", string.Empty); dictionary.Add("copycompletetest", true); } else { string paramStrToSend = string.Empty; int i = 0; foreach (var item in copyTestDataModel.TestDataIdList) { if (i == 0) { paramStrToSend = item.ToString(); i++; } else { paramStrToSend = paramStrToSend + "," + item.ToString(); } } dictionary.Add("testdataids", paramStrToSend); dictionary.Add("copycompletetest", false); } var mapper = this.mapperFactory.GetMapper <TblTestData, TblTestDataDto>(); this.Table.SqlQuery <TblTestDataDto>("Select * from proccopytestdata(@fromtestid,@totestid,@createdby,@testdataids,@copycompletetest);", dictionary).ToList(); return(true); }
/// <summary> /// Copy the test steps from one test to another /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="copyTestDataModel">copyTestDataModel Object</param> /// <returns> /// TblTestDataDto List object /// </returns> public ResultMessage <IEnumerable <TblTestDataDto> > CopyTestData(long userId, CopyTestDataModel copyTestDataModel) { var result = new ResultMessage <IEnumerable <TblTestDataDto> >(); if (copyTestDataModel.FromTestId > 0 && copyTestDataModel.TestDataIdList.Count > 0 && copyTestDataModel.ToTestId > 0) { var mapper = this.mapperFactory.GetMapper <TblTestData, TblTestDataDto>(); List <TblTestDataDto> testDataList = this.Table.Find(t => copyTestDataModel.TestDataIdList.Contains(t.Id)).OrderBy(m => m.ExecutionSequence).Select(mapper.Map).ToList(); long executionSequence = 1; testDataList.ForEach(m => { m.Id = 0; m.ExecutionSequence = executionSequence++; m.TestId = copyTestDataModel.ToTestId; if (m.LinkTestType == (int)LinkTestType.TestStep || m.LinkTestType == (int)LinkTestType.SharedWebsiteTest) { this.SaveOrUpdate(m, userId); } else { this.SaveOrUpdateWithSharedTest(userId, m); } }); } return(result); }