public async Task <int> CreateBeehiveAsync( string ownerId, string creatorId, int number, BeehiveSystem beehiveSystem, BeehiveType beehiveType, DateTime dateTime, int apiaryId, BeehivePower beehivePower, bool hasDevice, bool hasPolenCatcher, bool hasPropolisCatcher, bool isItMovable) { var beehive = new Beehive { CreatorId = creatorId, OwnerId = ownerId, Number = number, BeehiveSystem = beehiveSystem, BeehiveType = beehiveType, BeehivePower = beehivePower, Date = dateTime, ApiaryId = apiaryId, HasDevice = hasDevice, HasPolenCatcher = hasPolenCatcher, HasPropolisCatcher = hasPropolisCatcher, IsItMovable = isItMovable, }; await this.beehiveRepository.AddAsync(beehive); await this.beehiveRepository.SaveChangesAsync(); if (beehive.Apiary.ApiaryType == ApiaryType.Movable) { await this.temporaryApiaryBeehiveService.AddBeehiveToApiary(apiaryId, beehive.Id); } var allApiaryHelpersIds = this.apiaryHelperRepository .All() .Where(x => x.ApiaryId == apiaryId) .Select(x => x.UserId); foreach (var helperId in allApiaryHelpersIds) { var helper = new BeehiveHelper { UserId = helperId, BeehiveId = beehive.Id, }; await this.beehiveHelperRepository.AddAsync(helper); } await this.beehiveHelperRepository.SaveChangesAsync(); return(beehive.Id); }
public async Task AddAsync(string userId, int beehiveId) { var beehiveHelper = new BeehiveHelper() { Access = Access.Read, BeehiveId = beehiveId, UserId = userId, }; await this.beehiveHelperRepository.AddAsync(beehiveHelper); }
public async Task AddAsync(string userId, int apiaryId) { var newApiaryHelper = new ApiaryHelper { ApiaryId = apiaryId, UserId = userId, Access = Access.Read, }; await this.apiaryHelperRepository.AddAsync(newApiaryHelper); await this.apiaryHelperRepository.SaveChangesAsync(); var allBeehives = this.beeheiveRepository .All() .Where(b => b.ApiaryId == apiaryId) .ToList(); foreach (var beehive in allBeehives) { var helper = new BeehiveHelper { Access = Access.Read, BeehiveId = beehive.Id, UserId = userId, }; await this.beehiveHelperRepository.AddAsync(helper); } await this.beehiveHelperRepository.SaveChangesAsync(); var allQueensIds = this.beeheiveRepository .All() .Where(b => b.ApiaryId == apiaryId) .Select(b => b.QueenId) .ToList(); foreach (var queenId in allQueensIds) { if (queenId.HasValue) { var helper = new QueenHelper { QueenId = queenId.Value, UserId = userId, Access = Access.Read, }; await this.queenHelperRepository.AddAsync(helper); } } await this.queenHelperRepository.SaveChangesAsync(); }
public void EndAdd(Mobile from, object o) { if (o is Item && ((Item)o).IsChildOf(from.Backpack)) { if (o is Beeswax) { //error checking if (UsesRemaining < 1) { from.PrivateOverheadMessage(0, 1154, false, "The pot is too damaged to melt any more wax.", from.NetState); return; } else if (m_Beeswax >= MaxWax) { from.PrivateOverheadMessage(0, 1154, false, "The pot cannot hold any more wax.", from.NetState); return; } else if (!BeehiveHelper.HasHeatSource(from)) { from.PrivateOverheadMessage(0, 1154, false, "You must be near a heat source to melt beeswax.", from.NetState); return; } Beeswax wax = (Beeswax)o; if ((wax.Amount + MeltedBeeswax) > MaxWax) { wax.Amount -= (MaxWax - MeltedBeeswax); MeltedBeeswax = MaxWax; } else { MeltedBeeswax += wax.Amount; wax.Delete(); } from.PrivateOverheadMessage(0, 1154, false, "You slowly melt the beeswax and mix it in the pot.", from.NetState); this.ItemID = 5162; //change the graphic from.PlaySound(43); //bellow sound //from.PlaySound( 0x21 ); //bubbling sound UsesRemaining--; if (MeltedBeeswax < MaxWax) { BeginAdd(from); } } else if (o == this) { //empty the pot if (MeltedBeeswax < 1) { from.PrivateOverheadMessage(0, 1154, false, "There is no wax in the pot.", from.NetState); } else { Item wax = new Beeswax(MeltedBeeswax); if (!from.PlaceInBackpack(wax)) { wax.Delete(); from.PrivateOverheadMessage(0, 1154, false, "There is not enough room in your backpack for the wax!", from.NetState); return; } MeltedBeeswax = 0; ItemID = 2541; //empty pot from.PrivateOverheadMessage(0, 1154, false, "You empty the pot and place the beeswax in your pack.", from.NetState); } } else { from.PrivateOverheadMessage(0, 1154, false, "You can only melt pure beeswax in the pot.", from.NetState); } } else { from.PrivateOverheadMessage(0, 1154, false, "The wax must be in your pack to target it.", from.NetState); } }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; if (info.ButtonID == 0 || m_Pot.Deleted || !from.InRange(m_Pot.GetWorldLocation(), 3)) { return; } if (!m_Pot.IsAccessibleTo(from)) { from.PrivateOverheadMessage(0, 1154, false, "I cannot use that.", from.NetState); return; } switch (info.ButtonID) { case (int)Buttons.cmdHelp: { from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); from.SendGump(new BeehiveHelpGump(from, 1)); break; } case (int)Buttons.cmdAddRaw: //Add Raw Honey { from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); if (m_Pot.PureBeeswax > 0) { from.PrivateOverheadMessage(0, 1154, false, "You cannot mix raw beeswax with rendered wax. Please empty the pot first.", from.NetState); return; } from.PrivateOverheadMessage(0, 1154, false, "Choose the raw beeswax you wish to add to the pot.", from.NetState); m_Pot.BeginAdd(from); break; } case (int)Buttons.cmdEmptyPot: //Empty the pot { if (m_Pot.PureBeeswax < 1 && m_Pot.RawBeeswax < 1) { from.PrivateOverheadMessage(0, 1154, false, "There is no wax in the pot.", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); return; } Item wax; if (m_Pot.PureBeeswax > 0) { wax = new Beeswax(m_Pot.PureBeeswax); } else { wax = new RawBeeswax(m_Pot.RawBeeswax); } if (!from.PlaceInBackpack(wax)) { wax.Delete(); from.PrivateOverheadMessage(0, 1154, false, "There is not enough room in your backpack for the wax!", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); break; } m_Pot.RawBeeswax = 0; m_Pot.PureBeeswax = 0; m_Pot.ItemID = 2532; //empty pot from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); from.PrivateOverheadMessage(0, 1154, false, "You place the beeswax in your pack.", from.NetState); break; } case (int)Buttons.cmdRenderWax: //render the wax { if (m_Pot.UsesRemaining < 1) { //no uses remaining from.PrivateOverheadMessage(0, 1154, false, "The pot is too damamged to render beeswax.", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); return; } else if (m_Pot.PureBeeswax > 1) { //already rendered from.PrivateOverheadMessage(0, 1154, false, "The pot is already full of rendered beeswax.", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); return; } else if (m_Pot.RawBeeswax < 10) { //not enough raw beeswax from.PrivateOverheadMessage(0, 1154, false, "There is not enough raw beeswax in the pot.", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); return; } else if (!BeehiveHelper.HasHeatSource(from)) { //need a heat source to melt the wax from.PrivateOverheadMessage(0, 1154, false, "You must be near a heat source to render beeswax.", from.NetState); from.SendGump(new BeehiveSmallPotGump(from, m_Pot)); return; } m_Pot.ItemID = 0x142b; //pot overflowing with wax m_Pot.UsesRemaining--; if (m_Pot.UsesRemaining < 0) { m_Pot.UsesRemaining = 0; } int waste = Utility.RandomMinMax(1, m_Pot.RawBeeswax / 5); if (GiveSlumgum) { //give slumgum Item gum = new Slumgum(Math.Max(1, waste)); if (!from.PlaceInBackpack(gum)) { gum.Delete(); } } from.PlaySound(0x21); from.PrivateOverheadMessage(0, 1154, false, "You slowly melt the raw beeswax and remove the impurities.", from.NetState); m_Pot.PureBeeswax = m_Pot.RawBeeswax - waste; m_Pot.RawBeeswax = 0; break; } } }