public BaseItem GetItemFromCashID(long cashId, int itemid = 0) { if (itemid == 0) { var possibleItem = GetLockerItemFromCashID(cashId); if (possibleItem == null) { return(null); } itemid = possibleItem.ItemId; } if (Constants.isEquip(itemid)) { return(Equips.FirstOrDefault(x => x.CashId == cashId)); } else if (Constants.isPet(itemid)) { return(Pets.FirstOrDefault(x => x.CashId == cashId)); } else { return(Bundles.FirstOrDefault(x => x.CashId == cashId)); } }
public bool Remove(string name) { Pet pet = Pets.FirstOrDefault(x => x.Name == name); if (pet != null) { this.pets.Remove(pet); return(true); } return(false); }
public async Task <Pet> GetPet(int petId) { await Task.Delay(1000); return(Pets.FirstOrDefault(x => x.Id == petId)); }
protected void LoadFile() { if (File.Exists($@"{Environment.CurrentDirectory}\{fileName}")) { XmlSerializer serializer = null; TextReader reader = null; try { serializer = new XmlSerializer(this.GetType()); reader = new StreamReader(fileName); DBDataContext db = (DBDataContext)serializer.Deserialize(reader); this.Species = db.Species; this.Addresses = db.Addresses; this.UserTypes = db.UserTypes; this.Users = db.Users; this.Pets = db.Pets; this.Clients = db.Clients; this.Appointments = db.Appointments; this.Doctors = db.Doctors; this.AppointmentTypes = db.AppointmentTypes; Addresses.ForEach(item => item.Client = Clients.FirstOrDefault(r => r.Id == item.IdClient)); Users.ForEach(item => item.UserType = UserTypes.FirstOrDefault(r => r.Id == item.IdUserType)); Pets.ForEach(item => { item.Specie = Species.FirstOrDefault(r => r.Id == item.IdSpecie); item.Owner = Clients.FirstOrDefault(r => r.Id == item.IdOwner); }); Clients.ForEach(item => { item.Pets = Pets.Where(r => r.IdOwner == item.Id).ToList(); item.Addresses = Addresses.Where(r => r.IdClient == item.Id).ToList(); }); Appointments.ForEach(item => { item.Pet = Pets.FirstOrDefault(r => r.Id == item.IdPet); item.Address = Addresses.FirstOrDefault(r => r.Id == item.IdAddress); item.Doctor = Doctors.FirstOrDefault(r => r.Id == item.IdDoctor); item.Client = Clients.FirstOrDefault(r => r.Id == item.Pet.IdOwner); item.AppointmentType = AppointmentTypes.FirstOrDefault(r => r.Id == item.IdAppointmentType); }); } catch (Exception ex) { throw ex; } finally { if (reader != null) { reader.Close(); } if (serializer != null) { GC.SuppressFinalize(serializer); } } } }