public static StrategyModel ToModel(this StrategyEntity SE) { if (SE != null) { BossesPerZoneRepository repoBZ = new BossesPerZoneRepository(); CharactersConfigurationRepository repoCC = new CharactersConfigurationRepository(); UserRepository repoU = new UserRepository(); StrategyModel SM = new StrategyModel(); SM.User = repoU.GetOne(SE.UserId).MapTo <UserModel>(); SM.CharactersConfiguration = repoCC.GetOne(SE.CharactersConfigurationId).ToModel(); SM.BossZone = repoBZ.GetOne(SE.BossZoneId).ToModel(); SM.ImagePath1 = SE.ImagePath1; SM.ImagePath2 = SE.ImagePath2; SM.ImagePath3 = SE.ImagePath3; SM.ImagePath4 = SE.ImagePath4; SM.Description = SE.Description; SM.Note = SE.Note; SM.Id = SE.Id; SM.Active = SE.Active; return(SM); } else { return(null); } }
public void Update(int Id, StrategyEntity T) { using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["API"].ConnectionString)) { using (SqlCommand cmd = c.CreateCommand()) { if (T != null && T.ImagePath1 != null && T.ImagePath2 != null && T.ImagePath3 != null && T.ImagePath4 != null && T.CharactersConfigurationId != 0 && T.BossZoneId != 0 && T.UserId != 0 && Id != 0) { cmd.CommandText = "SP_UpdateStrategy"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter BossZoneId = new SqlParameter("BossZoneId", T.BossZoneId); SqlParameter CharactersConfigurationId = new SqlParameter("CharactersConfigurationId", T.CharactersConfigurationId); SqlParameter ImagePath1 = new SqlParameter("ImagePath1", T.ImagePath1); SqlParameter ImagePath2 = new SqlParameter("ImagePath2", T.ImagePath2); SqlParameter ImagePath3 = new SqlParameter("ImagePath3", T.ImagePath3); SqlParameter ImagePath4 = new SqlParameter("ImagePath4", T.ImagePath4); SqlParameter Note = new SqlParameter("Note", T.Note); SqlParameter UserId = new SqlParameter("UserId", T.UserId); SqlParameter PId = new SqlParameter("Id", Id); cmd.Parameters.Add(BossZoneId); cmd.Parameters.Add(CharactersConfigurationId); cmd.Parameters.Add(ImagePath1); cmd.Parameters.Add(ImagePath2); cmd.Parameters.Add(ImagePath3); cmd.Parameters.Add(ImagePath4); cmd.Parameters.Add(Note); cmd.Parameters.Add(UserId); cmd.Parameters.Add(PId); c.Open(); cmd.ExecuteNonQuery(); } } } }
public void DependOnStrategy() { StrategyEntity strategy = Factory.GetStrategyEntity(); bool result = TestObject.AddDependency(strategy); Assert.IsFalse(result, "Should not be able to depend on other Strategy entities."); }
public static StrategyEntity ToEntity(this StrategyModel SM) { if (SM != null) { StrategyEntity SE = new StrategyEntity(); SE.UserId = SM.User.Id; SE.CharactersConfigurationId = SM.CharactersConfiguration.Id; SE.BossZoneId = SM.BossZone.Id; SE.ImagePath1 = SM.ImagePath1; SE.ImagePath2 = SM.ImagePath2; SE.ImagePath3 = SM.ImagePath3; SE.ImagePath4 = SM.ImagePath4; SE.Note = SM.Note; SE.Id = SM.Id; SE.Active = SM.Active; return(SE); } else { return(null); } }
public StrategyEntity GetOne(int id) { using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["API"].ConnectionString)) { using (SqlCommand cmd = c.CreateCommand()) { cmd.CommandText = "SELECT * FROM Strategies WHERE Id = @Id AND Active = 1"; cmd.Parameters.AddWithValue("Id", id); c.Open(); using (SqlDataReader Tab = cmd.ExecuteReader()) { if (Tab.Read()) { StrategyEntity S = new StrategyEntity() { Id = (int)Tab["Id"], BossZoneId = (int)Tab["BossZoneId"], CharactersConfigurationId = (int)Tab["CharactersConfigurationId"], ImagePath1 = Tab["ImagePath1"].ToString(), ImagePath2 = Tab["ImagePath2"].ToString(), ImagePath3 = Tab["ImagePath3"].ToString(), ImagePath4 = Tab["ImagePath4"].ToString(), UserId = (int)Tab["UserId"], Note = (int)Tab["Note"], Active = (int)Tab["Active"] }; return(S); } else { return(null); } } } } }
public void Update(StrategyEntity item) { _strategies.RemoveAll(dto => dto.Id == item.Id); _strategies.Add(item); }
public void Create(StrategyEntity item) { _strategies.Add(item); }
public void Initialise() { TestObject = Factory.GetStrategyEntity(); Assert.IsNotNull(TestObject, "Failed to instantiate TestObject."); }