public Equipment(Character character, Dictionary <string, EquipmentItem> initDict) { AttachedCharacter = character; this.Slot = initDict; ItemDAO = new ItemJsonDAO(jsonPath); }
public bool Update(IItemDAO dao) { bool res = false; try { using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities()) { DataModel.tblItem item = db.tblItems.Where(x => x.ID == dao.ID).FirstOrDefault(); if (item != null) { item.Name = dao.Name; item.ParameterA = dao.ParameterA; item.ParameterB = dao.ParameterB; int i = db.SaveChanges(); res = true; } } } catch { res = false; } return(res); }
public bool Update(IItemDAO dao) { bool res = false; string sql = "UPDATE tblItems SET [Name]=@name, [ParameterA]=@parametera, [ParameterB]=@parameterb WHERE [ID]=@id"; using (SQLiteConnection con = new SQLiteConnection(this.cs)) { SQLiteCommand cmd = new SQLiteCommand(sql, con); SQLiteParameter id = new SQLiteParameter("id", dao.ID); SQLiteParameter name = new SQLiteParameter("name", dao.Name); SQLiteParameter parametera = new SQLiteParameter("parametera", dao.ParameterA); SQLiteParameter parameterb = new SQLiteParameter("parameterb", dao.ParameterB); cmd.Parameters.Add(id); cmd.Parameters.Add(name); cmd.Parameters.Add(parametera); cmd.Parameters.Add(parameterb); try { con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows == 1) { res = true; } con.Close(); } catch (Exception ex) { con.Close(); } } return(res); }
public long Add(IItemDAO dao) { object r = null; string sql = "INSERT INTO tblItems ([Name], [ParameterA], [ParameterB]) VALUES (@name, @parametera, @parameterb); SELECT last_insert_rowid();"; using (SQLiteConnection con = new SQLiteConnection(this.cs)) { SQLiteCommand cmd = new SQLiteCommand(sql, con); SQLiteParameter name = new SQLiteParameter("name", dao.Name); SQLiteParameter parametera = new SQLiteParameter("parametera", dao.ParameterA); SQLiteParameter parameterb = new SQLiteParameter("parameterb", dao.ParameterB); cmd.Parameters.Add(name); cmd.Parameters.Add(parametera); cmd.Parameters.Add(parameterb); try { con.Open(); r = cmd.ExecuteScalar(); con.Close(); } catch { con.Close(); } } if (r != null) { return((long)r); } return(0); }
public long Add(IItemDAO dao) { long id = 0; DataModel.tblItem item = new DataModel.tblItem(); item.Name = dao.Name; item.ParameterA = dao.ParameterA; item.ParameterB = dao.ParameterB; try { using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities()) { db.tblItems.Add(item); int i = db.SaveChanges(); id = item.ID; } } catch { id = 0; } return(id); }
public ItemBO(IDALItemManager itemManager, IItemDAO dao) { this.itemManager = itemManager; this.id = dao.ID; this.name = dao.Name; this.parameterA = dao.ParameterA; this.parameterB = dao.ParameterB; }
public IItemBO GetItem(long id) { IItemDAO dao = this.itemManager.Get(id); if (dao == null) { return(null); } return(new ItemBO(this.itemManager, dao)); }
public Equipment(Character character, EquipmentItem main, EquipmentItem off, EquipmentItem body, EquipmentItem charm1, EquipmentItem charm2) { Slot["MainHand"] = main; Slot["OffHand"] = off; Slot["Body"] = body; Slot["Charm 1"] = charm1; Slot["Charm 2"] = charm2; AttachedCharacter = character; ItemDAO = new ItemJsonDAO(jsonPath); }
public IItemDAO Get(long id) { IItemDAO res = null; try { using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities()) { res = db.tblItems.Where(x => x.ID == id).FirstOrDefault(); } } catch (Exception ex) { res = null; } return(res); }
public bool IsExist(long id) { bool res = false; try { using (DataModel.DatabaseEntities db = new DataModel.DatabaseEntities()) { IItemDAO item = db.tblItems.Where(x => x.ID == id).FirstOrDefault(); if (item != null) { res = true; } } } catch { res = false; } return(res); }
public IItemDAO Get(long id) { IItemDAO res = null; string sql = "SELECT * FROM tblItems WHERE [ID]=@id"; using (SQLiteConnection con = new SQLiteConnection(this.cs)) { SQLiteCommand cmd = new SQLiteCommand(sql, con); SQLiteParameter p = new SQLiteParameter("id", id); cmd.Parameters.Add(p); try { con.Open(); using (SQLiteDataReader r = cmd.ExecuteReader()) { if (r.HasRows) { r.Read(); res = new ItemDAO(); res.ID = Convert.ToInt64(r["ID"]); res.Name = Convert.ToString(r["Name"]); res.ParameterA = Convert.ToDouble(r["ParameterA"]); res.ParameterB = Convert.ToDouble(r["ParameterB"]); } r.Close(); } con.Close(); } catch { con.Close(); res = null; } } return(res); }
public Requirements() { ItemDAO = new ItemJsonDAO(jsonPath); }
public Profession() { ItemDAO = new ItemJsonDAO(jsonPath); }
public ItemController(IItemDAO itemDAO, IBidDAO bidDAO) { this.itemDao = itemDAO; this.bidDao = bidDAO; }
public ItemCreation() { ItemDAO = new ItemJsonDAO(jsonPath); }
public EquipmentBehavior() { ItemDAO = new ItemJsonDAO(jsonPath); }
public InventoryBehavior() { ItemDAO = new ItemJsonDAO(jsonPath); }
public ComandaBussines(IComandaDAO comandaDAO, IItemDAO itemDAO) { _comandaDAO = comandaDAO; _itemDAO = itemDAO; }
public Equipment() { ItemDAO = new ItemJsonDAO(jsonPath); }