public void DeleteTA(TA ta, ref List<string> errors) { var conn = new SqlConnection(ConnectionString); try { var adapter = new SqlDataAdapter(DeleteTAProcedure, conn) { SelectCommand = { CommandType = CommandType .StoredProcedure } }; adapter.SelectCommand.Parameters.Add(new SqlParameter("@ta_id", SqlDbType.Int)); adapter.SelectCommand.Parameters.Add(new SqlParameter("@schedule_id", SqlDbType.Int)); adapter.SelectCommand.Parameters["@ta_id"].Value = ta.TA_Id_int; adapter.SelectCommand.Parameters["@schedule_id"].Value = ta.Schedule_Id; var dataSet = new DataSet(); adapter.Fill(dataSet); } catch (Exception e) { errors.Add("Error: " + e); } finally { conn.Dispose(); } }
public string InsertTa(TA ta) { var errors = new List<string>(); var repository = new TARepository(); var service = new TaService(repository); service.InsertTA(null, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void InsertTaErrorTest2() { //// Arranage var errors = new List<string>(); var mockRepository = new Mock<ITARepository>(); var taservice = new TaService(mockRepository.Object); var ta = new TA { TA_Id = string.Empty }; //// Act taservice.InsertTA(ta, ref errors); //// Assert Assert.AreEqual(1, errors.Count); }
public string UpdateStudent(TA ta) { var errors = new List<string>(); var repository = new TARepository(); var service = new TaService(repository); service.UpdateTA(ta, ref errors); if (errors.Count == 0) { return "ok"; } return "error"; }
public void InsertTA(TA ta, ref List<string> errors) { if (ta == null) { errors.Add("TA cannot be null"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.TA_Id)) { errors.Add("Invalid TA id"); throw new ArgumentException(); } this.repository.InsertTA(ta, ref errors); }
public void DeleteTA(TA ta, ref List<string> errors) { if (string.IsNullOrEmpty(ta.TA_Id)) { errors.Add("Invalid TA id"); throw new ArgumentException(); } if (string.IsNullOrEmpty(ta.Schedule_Id)) { errors.Add("Invalid Schedule id"); throw new ArgumentException(); } this.repository.DeleteTA(ta, ref errors); }
public List<TA> GetTAList(ref List<string> errors) { var conn = new SqlConnection(ConnectionString); var ta_List = new List<TA>(); try { var adapter = new SqlDataAdapter(GetTAProcedure, conn) { SelectCommand = { CommandType = CommandType.StoredProcedure } }; var dataSet = new DataSet(); adapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count == 0) { return null; } for (var i = 0; i < dataSet.Tables[0].Rows.Count; i++) { var talist = new TA { Schedule_Id = dataSet.Tables[0].Rows[i]["schdule_id"].ToString(), TA_Id = dataSet.Tables[0].Rows[i]["TA_id"].ToString() }; ta_List.Add(talist); } } catch (Exception e) { errors.Add("Error: " + e); } finally { conn.Dispose(); } return ta_List; }