public void UpdateTeam_MapFrom_WorksCorrectly() { var originalTeamName = _context.Teams.FirstOrDefault(t => t.TeamId == TeamId).Name; var existingTeam = _context.Teams.FirstOrDefault(t => t.TeamId == TeamId); var updatedTeam = new DbTeam { TeamId = TeamId, Location = "Minneapolis", Name = "Lakers", Division = "Northern", Conference = "Awesome", LastModified = DateTime.UtcNow, LastModifiedBy = "System Admin" }; existingTeam.MapFrom(updatedTeam); Assert.That(existingTeam.Location, Is.EqualTo(updatedTeam.Location)); Assert.That(existingTeam.Name, Is.EqualTo(updatedTeam.Name)); Assert.That(existingTeam.Division, Is.EqualTo(updatedTeam.Division)); Assert.That(existingTeam.Conference, Is.EqualTo(updatedTeam.Conference)); Assert.That(existingTeam.LastModified, Is.EqualTo(updatedTeam.LastModified)); Assert.That(existingTeam.LastModifiedBy, Is.EqualTo(updatedTeam.LastModifiedBy)); Assert.That(existingTeam.Name, Is.Not.EqualTo(originalTeamName)); }
//UPDATE public int mTeamMemco(string pSiteCd, string pTeamCd, string pTeamNm, string pUsingFalg, string pSortNo, string pMemo) { int reCnt = 0; DbTeam db = null; try { string dbCon_IP = WebConfigurationManager.ConnectionStrings["ConnectionStr_IP"].ConnectionString; string dbCon_DB = WebConfigurationManager.ConnectionStrings["ConnectionStr_DB"].ConnectionString; string dbCon_USER = WebConfigurationManager.ConnectionStrings["ConnectionStr_USER"].ConnectionString; db = new DbTeam(dbCon_IP, dbCon_DB, dbCon_USER, "0"); reCnt = db.mTeamMemco(pSiteCd, pTeamCd, pTeamNm, pUsingFalg, pSortNo, pMemo); } catch (Exception ex) { _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::mCompanyMemco (Detail)::pSiteCd=[" + pSiteCd + "], pTeamCd=[" + pTeamCd + "], pTeamNm=[" + pTeamNm + "], pUsingFalg=[" + pUsingFalg + "]" + ", pSortNo=[" + pSortNo + "], pMemo=[" + pMemo + "]", "Error"); _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::mCompanyMemco (Detail)::" + "\r\n" + ex.ToString(), "Error"); } finally { if (db != null) { db.DisConnect(); } } return(reCnt); }
//INSERT TEAM WITH PROCEDURE public string aTeamPro(string pDbNm, Hashtable param, out Hashtable outVal) { string reVal = ""; DbTeam db = null; try { string dbCon_IP = WebConfigurationManager.ConnectionStrings["ConnectionStr_IP"].ConnectionString; string dbCon_DB = "Initial Catalog=PLUS-" + pDbNm + ";"; string dbCon_USER = WebConfigurationManager.ConnectionStrings["ConnectionStr_USER"].ConnectionString; db = new DbTeam(dbCon_IP, dbCon_DB, dbCon_USER, "1"); reVal = db.aTeamPro(param, out outVal); } catch (Exception ex) { outVal = null; _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::aTeamPro (Detail)::" + "\r\n" + ex.ToString(), "Error"); } finally { if (db != null) { db.DisConnect(); } } return(reVal); }
//COMPANY CMB BOX public DataSet companyCmb(string pSiteCd) { DataSet ds = null; DbTeam db = null; try { string dbCon_IP = WebConfigurationManager.ConnectionStrings["ConnectionStr_IP"].ConnectionString; string dbCon_DB = WebConfigurationManager.ConnectionStrings["ConnectionStr_DB"].ConnectionString; string dbCon_USER = WebConfigurationManager.ConnectionStrings["ConnectionStr_USER"].ConnectionString; db = new DbTeam(dbCon_IP, dbCon_DB, dbCon_USER, "0"); ds = db.companyCmb(pSiteCd); } catch (Exception ex) { _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::companyCmb (Detail)::" + "\r\n" + ex.ToString(), "Error"); } finally { if (db != null) { db.DisConnect(); } } return(ds); }
public static DbTeam SqlGetSingleTeam(string id) { DbTeam rtnItem = null; using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString)) { SqlCommand cmd = new SqlCommand(@"SELECT * FROM dbo.DB_TEAM WHERE TEAM_ID = @TeamId", sqlConnection); cmd.Parameters.AddWithValue("@TeamId", id); sqlConnection.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { rtnItem = new DbTeam(); rtnItem.TeamId = reader["TEAM_ID"].ToString(); rtnItem.TeamName = reader["TEAM_NAME"].ToString(); } } } return(rtnItem); }
//SELECT TEAM public DataSet sTeam(string pSiteCd, string pCoCd, string pUsingFlag, string pTeamNm) { DataSet ds = null; DbTeam db = null; try { string dbCon_IP = WebConfigurationManager.ConnectionStrings["ConnectionStr_IP"].ConnectionString; string dbCon_DB = WebConfigurationManager.ConnectionStrings["ConnectionStr_DB"].ConnectionString; string dbCon_USER = WebConfigurationManager.ConnectionStrings["ConnectionStr_USER"].ConnectionString; db = new DbTeam(dbCon_IP, dbCon_DB, dbCon_USER, "0"); ds = db.sTeam(pSiteCd, pCoCd, pUsingFlag, pTeamNm); } catch (Exception ex) { _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::sTeam (Detail)::pSiteCd=[" + pSiteCd + "], pCoCd=[" + pCoCd + "], pUsingFlag=[" + pUsingFlag + "], pTeamNm=[" + pTeamNm + "]" , "Error"); _logs.SaveLog("[error] (page)::BizTeam.cs (Function)::sTeam (Detail)::" + "\r\n" + ex.ToString(), "Error"); } finally { if (db != null) { db.DisConnect(); } } return(ds); }
public static DbTeam CopyWithoutNavigationProperties(DbTeam dbTeam) { return(new DbTeam { Id = dbTeam.Id, Name = dbTeam.Name }); }
public static void MapFrom(this DbTeam existingTeam, DbTeam updatedTeam) { existingTeam.Location = updatedTeam.Location; existingTeam.Name = updatedTeam.Name; existingTeam.Division = updatedTeam.Division; existingTeam.Conference = updatedTeam.Conference; existingTeam.LastModified = updatedTeam.LastModified; existingTeam.LastModifiedBy = updatedTeam.LastModifiedBy; }
public void AddTeam(CoreNewTeam coreTeam) { var dbTeam = new DbTeam { TeamName = coreTeam.TeamName }; _context.DbTeams.Add(dbTeam); _context.SaveChanges(); }
public void DeleteTeam(DbTeam deletedTeam) { var existingTeam = _context.Teams.FirstOrDefault(t => t.TeamId == deletedTeam.TeamId); existingTeam.IsDeleted = true; SetDateAndUserUpdatedInfo(existingTeam); _context.Teams.AddOrUpdate(existingTeam); _context.SaveChanges(); }
public void UpdateTeam(DbTeam updatedTeam) { SetDateAndUserUpdatedInfo(updatedTeam); var existingTeam = _context.Teams.FirstOrDefault(t => t.TeamId == updatedTeam.TeamId); existingTeam.MapFrom(updatedTeam); _context.Teams.AddOrUpdate(existingTeam); _context.SaveChanges(); }
/// <summary> /// Converts a persistent instance to a domain instance. /// </summary> /// <param name="dbTeam">Persistent instance to be converted.</param> /// <returns>Domain instance after conversion.</returns> private Team ToTeam(DbTeam dbTeam) { return(new Team { Id = dbTeam.Id, Name = dbTeam.Name, YearFormed = dbTeam.YearFormed, ChampionshipsWon = dbTeam.ChampionshipsWon, HasPaidEntryFee = dbTeam.HasPaidEntryFee }); }
public bool CreateTeam(DbTeam dbTeam, Guid projectId, Guid userId) { if (_projectRepository.IsAdmin(projectId, userId)) { dbTeam.CreatorId = userId; _dbSet.Add(dbTeam); return(true); } else { return(false); } }
public List <Usuario> Listar() { try { using (var ctx = new DbTeam()) { return(ctx.Usuario.ToList()); } } catch (Exception) { throw; } }
public Empresa Obtener(int id) { try { using (var ctx = new DbTeam()) { return(ctx.Empresa.Where(x => x.Emp_id == id).SingleOrDefault()); } } catch (Exception) { throw; } }
public Empresa Obtener(string strEmpresa) { try { using (var ctx = new DbTeam()) { return(ctx.Empresa.Where(x => x.Emp_Cia.ToUpper() == strEmpresa.ToUpper()).SingleOrDefault()); } } catch (Exception) { throw; } }
public List <Empresa> Listar() { try { using (var ctx = new DbTeam()) { return(ctx.Empresa.ToList()); } } catch (Exception) { throw; } }
public Usuario Consegir(string strUsuarios) { try { using (var ctx = new DbTeam()) { return(ctx.Usuario.Where(x => x.Us_Usuario == strUsuarios).SingleOrDefault()); } } catch (Exception) { throw; } }
public Usuario Obtener2(int id) { try { using (var ctx = new DbTeam()) { return(ctx.Usuario.Where(x => x.Us_Id == id).SingleOrDefault()); } } catch (Exception) { throw; } }
public void Actualizar(Empresa Emp) { try { using (var ctx = new DbTeam()) { ctx.Entry(Emp).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Actualizar(UsuarioPermiso Usr) { try { using (var ctx = new DbTeam()) { ctx.Entry(Usr).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public Usuario Obtener(string strUsuario, string strPass, string strEmpresa) { try { strPass = M_Seguridad.Encriptar(strPass); using (var ctx = new DbTeam()) { return(ctx.Usuario.Where(x => x.Us_Usuario == strUsuario && x.Us_Password == strPass && x.Us_Empresa == strEmpresa).SingleOrDefault()); } } catch (Exception) { throw; } }
public void Guardar(UsuarioPermiso Usr) { try { using (var ctx = new DbTeam()) { ctx.UsuarioPermiso.Add(Usr); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Actualizar(Usuario Usr) { try { Usr.Us_Password = M_Seguridad.Encriptar(Usr.Us_Password.Trim()); using (var ctx = new DbTeam()) { ctx.Entry(Usr).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Eliminar(int id) { try { using (var ctx = new DbTeam()) { var vBase = ctx.Usuario.Where(x => x.Us_Id == id).SingleOrDefault(); ctx.Usuario.Remove(vBase); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Eliminar(int id) { try { using (var ctx = new DbTeam()) { var vEmpresa = ctx.Empresa.Where(x => x.Emp_id == id).SingleOrDefault(); ctx.Empresa.Remove(vEmpresa); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Guardar(Empresa Emp) { try { using (var ctx = new DbTeam()) { if (ctx.Empresa.Count() == 0) { Emp.Emp_id = 1; } else { Emp.Emp_id = ctx.Empresa.Max(x => x.Emp_id) + 1; } ctx.Empresa.Add(Emp); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public void Guardar(Usuario Usr) { try { Usr.Us_Password = M_Seguridad.Encriptar(Usr.Us_Password); using (var ctx = new DbTeam()) { if (ctx.Usuario.Count() == 0) { Usr.Us_Id = 1; } else { Usr.Us_Id = ctx.Usuario.Max(x => x.Us_Id) + 1; } ctx.Usuario.Add(Usr); ctx.SaveChanges(); } } catch (Exception) { throw; } }
public static DbTeam SqlInsertTeam(DbTeam saveItem) { using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString)) { SqlCommand cmd = new SqlCommand(@"INSERT INTO dbo.DB_TEAM ( TEAM_ID, TEAM_NAME ) VALUES ( @TeamId, @TeamName )", sqlConnection); cmd.Parameters.AddWithValue("@TeamId", saveItem.TeamId); cmd.Parameters.AddWithValue("@TeamName", saveItem.TeamName); sqlConnection.Open(); cmd.ExecuteNonQuery(); } return(saveItem); }
public static async Task EchoMessage(ConnectorClient connector, Activity activity) { if (activity.Type.Equals("message")) { var channelThing = activity.GetChannelData <TeamsChannelData>(); string messagyBoi = activity.GetTextWithoutMentions(); Activity reply = null; //If you get the super secret channel save data command if (messagyBoi.Equals("Yo save channel data")) { //Check to see whether we've already got it DbChannel existingChannel = ShuffleSQLHelper.SqlGetSingleChannel(channelThing.Channel.Id, channelThing.Team.Id); if (existingChannel != null) { reply = activity.CreateReply($"Nah fam, you already got data for Channel: {existingChannel.ChannelName}"); } else { //If you channel id matches the team id, you're in the autogenerate General if (channelThing.Channel.Id.Equals(channelThing.Team.Id)) { var addChannel = new DbChannel() { ChannelId = channelThing.Channel.Id, TeamId = channelThing.Team.Id, ChannelName = "General" }; ShuffleSQLHelper.SqlInsertChannel(addChannel); reply = activity.CreateReply($"Added data for Channel: {addChannel.ChannelName}"); } else { //We gotta get the channels and figure out which one we're in var convoList = connector.GetTeamsConnectorClient().Teams.FetchChannelList(channelThing.Team.Id); var currentChannel = convoList.Conversations.First(x => x.Id.Equals(channelThing.Channel.Id)); var addChannel = new DbChannel() { ChannelId = currentChannel.Id, TeamId = channelThing.Team.Id, ChannelName = currentChannel.Name }; ShuffleSQLHelper.SqlInsertChannel(addChannel); reply = activity.CreateReply($"Added data for Channel: {addChannel.ChannelName}"); } } } else if (messagyBoi.Equals("Yo save team data")) { DbTeam existingTeam = ShuffleSQLHelper.SqlGetSingleTeam(channelThing.Team.Id); if (existingTeam != null) { reply = activity.CreateReply($"Nah fam, you already got data for Team: {existingTeam.TeamName}"); } else { var teamInfo = connector.GetTeamsConnectorClient().Teams.FetchTeamDetails(channelThing.Team.Id); var addTeam = new DbTeam() { TeamId = teamInfo.Id, TeamName = teamInfo.Name }; ShuffleSQLHelper.SqlInsertTeam(addTeam); reply = activity.CreateReply($"Added data for Team: {addTeam.TeamName}"); } } else { var members = await connector.Conversations.GetConversationMembersAsync(activity.Conversation.Id); //var reply = activity.CreateReply($"The members are {string.Join("\n\n", members.Select(x => x.Name))}"); reply = activity.CreateReply($"Shuffles Deck... Pulls Card\n\n"); Random rnd = new Random(); int poorSoul = rnd.Next(members.Count); reply.AddMentionToText(members[poorSoul], MentionTextLocation.AppendText); var newPull = new DbPull() { CallerName = activity.From.Name, PulledName = members[poorSoul].Name, TeamId = channelThing.Team.Id, ChannelId = channelThing.Channel.Id, PullMessage = messagyBoi, PullDate = DateTime.UtcNow }; ShuffleSQLHelper.SqlInsertPull(newPull); } await connector.Conversations.ReplyToActivityWithRetriesAsync(reply); } }