/** Add new entry to Gifts table - when reactivating an archived Gift (create a copy of archived entry) */ private async Task <BLLAppDTO.GiftBLL?> AddNewGiftBasedOnArchivedEntry(BLLAppDTO.ArchivedGiftResponseBLL archivedGift, Guid userId) { // Get existing Gift in Archived status var existingGift = Mapper.Map((await UOW.Gifts.GetAllArchivedForUserAsync(userId)) .SingleOrDefault(g => g.Id == archivedGift.GiftId)); if (existingGift == null) { throw new NotSupportedException($"Could not reactivate gift {archivedGift.GiftId.ToString()} - not found"); } // Create a copy but make it Active. Added gifts are by default isPinned=false. var copyOfGift = new BLLAppDTO.GiftBLL { Name = existingGift.Name, Description = existingGift.Description, Image = existingGift.Image, Url = existingGift.Url, PartnerUrl = existingGift.PartnerUrl, IsPartnered = existingGift.IsPartnered, IsPinned = false, WishlistId = existingGift.WishlistId, ActionTypeId = new Guid(_reservedId), StatusId = new Guid(_activeId) }; // Add var newActiveGift = UOW.Gifts.Add(Mapper.Map(copyOfGift), userId); // Track UOW.AddToEntityTracker(newActiveGift, copyOfGift); // Check added data var isGiftInActiveStatus = copyOfGift.StatusId.ToString().Equals(_activeId); return(newActiveGift != null && isGiftInActiveStatus ? copyOfGift : null); }
public ActionResult Edit([Bind(Prefix = "Tag")] Tag tag, [Bind(Include = "Images")] List <Guid> images) { Tag dbTag = UOW.Tags.GetById(tag.TagId); if (dbTag != null) { dbTag.Name = tag.Name; dbTag.IsActive = tag.IsActive; dbTag.IsFilter = tag.IsFilter; dbTag.Images.Clear(); if (images != null) { dbTag.Images = UOW.Images.GetSetByIds(images); } UOW.Commit(); tag = dbTag; } else { return(HttpNotFound()); } TagVM vm = new TagVM { Tag = tag, Images = UOW.Images.GetAll() }; return(View(vm)); }
internal bool IfExists(string articleNo) { using (UOW uow = new UOW()) { return(uow.ArticleRepository.Find(x => x.ArticleNo == articleNo).Any()); } }
public Client GetClientByClientPIB(string PIB) { using (UOW uow = new UOW()) { return(uow.ClientRepository.Find(x => x.PIB == PIB).FirstOrDefault()); } }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<God> gods = new List<God>() { God.Mars, God.Sophia, God.Poseidon, God.Zeus }; List<God> godsOrder = new List<God>(); for (int i = 0; i < context.players.PlayersCount - 1; ++i) { int randomGod = context.Randomizer.Range(0, gods.Count-1); godsOrder.Add(gods[randomGod]); gods.RemoveAt(randomGod); } List<int> gold = new List<int>(); for (int i = 0; i < context.players.PlayersCount; ++i ) { gold.Add(context.map.GetIncome(i)); } List<int> random = new List<int>(); int randomCount = context.cards.GetNewCardCountAfterShift(); int cardCount = Enum.GetValues(typeof(Card)).Length - 1; for (int i = 0; i < randomCount; i++) random.Add(context.Randomizer.Range(0, cardCount)); UnitOfWork uow = new UOW() { godsOrder = godsOrder, gold = gold, random = random }; return uow; }
public Article GetArticleByArticleNo(string articleNo) { using (UOW uow = new UOW()) { return(uow.ArticleRepository.Find(x => x.ArticleNo == articleNo).FirstOrDefault()); } }
public ActionResult Create([Bind(Prefix = "DesignReview")] DesignReview designReview) { if (ModelState.IsValid) { DesignReview newDesignReview = new DesignReview(); newDesignReview.Id = Guid.NewGuid(); newDesignReview.Title = designReview.Title; newDesignReview.Description = designReview.Description; newDesignReview.SelectedComment = designReview.SelectedComment; newDesignReview.AdditionalComment = designReview.AdditionalComment; newDesignReview.AcceptedDate = designReview.AcceptedDate; newDesignReview.IsActive = designReview.IsActive; newDesignReview.ProjectId = designReview.ProjectId; UOW.DesignReviews.Add(newDesignReview); UOW.Commit(); designReview = newDesignReview; } DesignReviewVM vm = new DesignReviewVM { DesignReview = designReview, Projects = UOW.Projects.GetAll() }; return(View("Edit", vm)); }
public static async Task <Store> GetStoreAsync( UOW uow, int storeId) { var store = StoreCredentials .Where(t => t.Id == storeId) .FirstOrDefault(); if (store != null) { return(store); } var storeRep = uow.GetRepository <StoreRepository>(); store = await storeRep.GetAICredentials(storeId); if (store == null) { var log = uow.GetRepository <LogRepository>(); await log.RecLog(Core.Logger.NopLogLevel.Error, $"Loja não encontrada. Utilizado failover para loja 1. LojaId: {storeId}"); return(await GetStoreAsync(uow, 1)); } StoreCredentials.Add(store); return(store); }
internal List <Article> GetArticleByName(string name) { using (UOW uow = new UOW()) { return(uow.ArticleRepository.Find(x => x.Name.Contains(name)).ToList()); } }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<int> turnPlayersOrder = new List<int>(); List<int> golds = new List<int>(context.players.PlayersCount); for (int i = 0; i < context.players.PlayersCount; ++i) golds.Add(0); for (int i = 0; i < context.auction.GodsOrder.Count; ++i) { AuctionCM.Bet bet = context.auction.GetMaxBetForGod(context.auction.GodsOrder[i]); if (bet != null) { golds[bet.playerID] = AuctionCM.GoldForBet(context.players.GetPlayer(bet.playerID), bet.bet); turnPlayersOrder.Add(bet.playerID); } } List<AuctionCM.Bet> apolloBets = context.auction.GetOrderedGodBets(God.Appolon); turnPlayersOrder.AddRange( apolloBets.Select(b => b.playerID).ToList() ); UOW uow = new UOW() { turnPlayersOrder = turnPlayersOrder, golds = golds }; return uow; }
public WSResponse <object> Cadastrar(Indicado indicado) { var resp = new WSResponse <object>(); try { if (ModelState.IsValid) { var uow = new UOW(); indicado.Status = Indicado.StatusLead.Pendente; indicado.CodParceiro = Convert.ToInt32(RequestContext.Principal.Identity.Name); indicado.DataEnvio = DateTime.Now; resp.Success = true; uow.IndicadoRep.Insert(indicado); uow.Save(); } foreach (var modelState in ModelState.Values) { foreach (var error in modelState.Errors) { resp.Errors.Add(error.ErrorMessage); } } return(resp); } catch (Exception e) { return(resp); } }
public Tuple <string, string> MergeInvestigacion(InvInstitucional investigacion) { using (uow = new UOW()) { var resultado = uow.InvestigacionRepository.MergeInvestigacion(investigacion); if (resultado.Item1 != "") { investigacion.IdInvestigacion = resultado.Item1; foreach (var item in investigacion.AreaLinea) { uow.InvestigacionRepository.MergeAreaLineaInv(item, investigacion.IdInvestigacion); } foreach (var item in investigacion.Investigadores) { uow.InvestigacionRepository.MergeInvestigadoresInv(item, investigacion.IdInvestigacion); } foreach (var item in investigacion.Producto) { uow.InvestigacionRepository.MergeProductoInv(item, investigacion.IdInvestigacion); } uow.InvestigacionRepository.MergeEstimulosInv(investigacion.Estimulos, investigacion.IdInvestigacion); uow.InvestigacionRepository.MergeEventosInv(investigacion.Eventos, investigacion.IdInvestigacion); foreach (var item in investigacion.Presupuesto) { uow.InvestigacionRepository.MergePresupuestoInv(item, investigacion.IdInvestigacion); } } else { return(new Tuple <string, string>("0", "Error al crear la investigacion")); } return(new Tuple <string, string>("1", " OK")); } }
public async Task <UserFriend> SendFriendRequest(UserFriend userFriend, Guid?userId = null, bool noTracking = true) { var uf = await GetExistingRequest(userFriend); if (uf == null) { if (userFriend.AppUserId == userFriend.RecipientId) { return(userFriend); } Add(userFriend); await UOW.SaveChangesAsync(); return(userFriend); } if (uf.Accepted) { return(uf); } if (uf.Pending) { return(uf); } uf.Pending = true; await UpdateAsync(uf); await UOW.SaveChangesAsync(); return(uf); }
public virtual void Save(T t) { var agg = GetById(t.ID); agg.EnsureNotNull(); var aggVersion = agg.Version; Monitor.Enter(_lockObj); using (UOW) { try { //保存未执行的事件 foreach (var @event in agg.UnCommitEvents) { aggVersion++; @event.Version = aggVersion; EventService.SaveEvent(@event); } UOW.Commit(); } catch { UOW.RollBack(); } } //发布消息,通知聚合根执行事件,并更改内存中的聚合根为最新状态 EventService.Publish(agg.UnCommitEvents); Monitor.Exit(_lockObj); }
public ActionResult Create([Bind(Prefix = "Account")] Account account, [Bind(Include = "Users")] List <Guid> users) { if (ModelState.IsValid) { Account newAccount = new Account(); newAccount.Id = Guid.NewGuid(); newAccount.Name = account.Name; newAccount.ClientSinceDate = account.ClientSinceDate; newAccount.CreatedDate = DateTime.Now; newAccount.IndustryType = account.IndustryType; newAccount.IsActive = account.IsActive; Counter dbCounter = UOW.Counters.GetByName("Account_Number"); int nextNumber = dbCounter.CurrentNumber = dbCounter.CurrentNumber + 1; newAccount.Number = nextNumber.ToString(); if (users != null) { newAccount.SkyberryUsers = UOW.SkyberryUsers.GetSetByIds(users); } UOW.Accounts.Add(newAccount); UOW.Commit(); account = newAccount; } AccountVM vm = new AccountVM { Account = account, Users = UOW.SkyberryUsers.GetAll() }; return(View("Edit", vm)); }
public ActionResult Login(Users User) { if (!ModelState.IsValid) { return(View(User)); } Users user = new Users(); Repository.Roles role = new Repository.Roles(); using (UOW uow = new UOW()) { user = uow._iUserRepository.Get().ToList().Where(x => x.UserName == User.UserName && x.Password == User.Password).FirstOrDefault(); if (user != null) { role = uow._iRoleRepository.Get().ToList().Where(x => x.Rid == user.Rid).FirstOrDefault(); FormsAuthentication.SetAuthCookie(User.UserName, false); var authTicket = new FormsAuthenticationTicket(1, User.UserName, DateTime.Now, DateTime.Now.AddMinutes(20), false, role.Role); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); HttpContext.Response.Cookies.Add(authCookie); return(RedirectToAction("Index", "Account")); } else { ModelState.AddModelError("", "Invalid login attempt."); return(RedirectToAction("Login", "Account")); } } }
public FormsController( UOW uow, IHostingEnvironment environment) { this.uow = uow ?? throw new System.ArgumentNullException(nameof(uow)); this.environment = environment ?? throw new System.ArgumentNullException(nameof(environment)); }
public ActionResult Edit([Bind(Prefix = "Account")] Account account, [Bind(Include = "Users")] List <Guid> users) { if (ModelState.IsValid) { Account dbAccount = UOW.Accounts.GetById(account.Id); if (dbAccount != null) { dbAccount.Name = account.Name; dbAccount.ClientSinceDate = account.ClientSinceDate; dbAccount.IndustryType = account.IndustryType; dbAccount.IsActive = account.IsActive; if (users != null) { dbAccount.SkyberryUsers = UOW.SkyberryUsers.GetSetByIds(users); } UOW.Commit(); account = dbAccount; } else { return(HttpNotFound()); } } AccountVM vm = new AccountVM { Account = account, Users = UOW.SkyberryUsers.GetAll() }; return(View(vm)); }
public List <Client> GetClientByName(string name) { using (UOW uow = new UOW()) { return(uow.ClientRepository.Find(x => x.Name.Contains(name)).ToList()); } }
public async Task TestInsertUpdateVote() { try { // now add a vote for candidate1 Vote vote = new Vote() { ElectionId = DefaultElectionId, BallotId = Guid.NewGuid(), CategoryId = PresCategoryId, CategoryTypeId = 2, SelectionId = BidenTicketId, VoteStatus = 0, ApprovalDate = DateTime.Now }; UOW.BeginTransaction(); Vote inserted = await voteRepository.Insert(UOW, vote); Assert.IsNotNull(inserted); Assert.IsTrue(inserted.Id != Guid.Empty, "Expect inserted vote Id not be empty"); // now change the ballot selection to candidate2 vote.Id = inserted.Id; vote.VoteStatus = (int)VoteStatusEnum.choiceRejected; Vote updated = await voteRepository.Update(UOW, vote); Assert.IsNotNull(updated); Assert.IsTrue(inserted.Id == updated.Id, "Expect inserted and updated Id to be the same"); UOW.CloseTransaction(); } catch (Exception ex) { Assert.IsNull(ex, "Exception Thrown: " + ex.Message); } }
private void bbiSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MsgDlg.Show("هل انت متأكد ؟", MsgDlg.MessageType.Question) == DialogResult.No) { return; } DevExpress.Xpo.AsyncCommitCallback CommitCallBack = (o) => { SplashScreenManager.CloseForm(); if (o == null) { MsgDlg.ShowAlert(Properties.Settings.Default.msg_SaveSuccess, MsgDlg.MessageType.Success, (Form)Parent.Parent.Parent); Logger.Info(Properties.Settings.Default.msg_SaveSuccess); } else { MsgDlg.ShowAlert(String.Format("{0}, {1}, {2}", Properties.Settings.Default.msg_SavingFailed, Environment.NewLine, o.Message), MsgDlg.MessageType.Error, (Form)Parent.Parent.Parent); Classes.Core.LogException(Logger, o.InnerException, Classes.Core.ExceptionLevelEnum.General, Classes.Managers.UserManager.defaultInstance.User.UserId); } }; SplashScreenManager.ShowForm(typeof(FixedAssets.Views.Main.WaitWindowFrm)); SplashScreenManager.Default.SetWaitFormDescription(Properties.Settings.Default.msg_SavingInProgress); UOW.CommitTransactionAsync(CommitCallBack); }
public ActionResult Edit([Bind(Prefix = "ImageSetItem")] ImageSetItem imageSetItem) { ImageSetItem dbImageSetItem = UOW.ImageSetItems.GetById(imageSetItem.ImageSetItemId); if (dbImageSetItem != null) { dbImageSetItem.ImageSetId = imageSetItem.ImageSetId; dbImageSetItem.ImageId = imageSetItem.ImageId; dbImageSetItem.Position = imageSetItem.Position; UOW.Commit(); imageSetItem = dbImageSetItem; } else { return(HttpNotFound()); } ImageSetItemVM vm = new ImageSetItemVM { ImageSetItem = imageSetItem, ImageSets = UOW.ImageSets.GetAll(), Images = UOW.Images.GetAll() }; return(View(vm)); }
public void RefreshData() { UOW.ReloadChangedObjects(); xpcGTDLChamCongTheoCa.Reload(); xpcCa.Reload(); gridUCList.DataSource = xpcGTDLChamCongTheoCa; }
public new BLLAppDTO.CampaignBLL Add(BLLAppDTO.CampaignBLL bllCampaign, object?userId = null) { // UserId is mandatory for adding Campaign if (userId == null) { throw new ArgumentNullException(nameof(userId)); } // Add new Campaign var dalCampaign = Mapper.Map(bllCampaign); var dalCampaignTracked = UOW.Campaigns.Add(dalCampaign); UOW.AddToEntityTracker(dalCampaignTracked, bllCampaign); var bllNewCampaign = Mapper.Map(dalCampaignTracked); // Add new UserCampaign. TODO: Should be done via EF probably somehow var userIdGuid = new Guid(userId.ToString()); var bllUserCampaign = new BLLAppDTO.UserCampaignBLL() { AppUserId = userIdGuid, CampaignId = bllNewCampaign.Id }; var dalUserCampaign = Mapper.MapUserCampaignToDAL(bllUserCampaign); var dalUserCampaignTracked = UOW.UserCampaigns.Add(dalUserCampaign); UOW.AddToEntityTracker(dalUserCampaignTracked, bllUserCampaign); Mapper.MapUserCampaignToBLL(dalUserCampaignTracked); return(bllNewCampaign); }
public ActionResult Create(EventData EventData) { string msg; try { //if (ModelState.IsValid) //{ using (UOW uow = new UOW()) { uow._iEventsDataRepository.Add(EventData); uow.SaveChanges(); } msg = "Saved Successfully"; //} //else //{ msg = "Validation data not successfull"; //} } catch (Exception ex) { msg = "Error occured:" + ex.Message; } return(View()); }
public override Item Add(Item entity) { var dalEntity = Mapper.Map(entity); var trackedDALEntity = Repository.Add(dalEntity); UOW.AddToEntityTracker(trackedDALEntity, entity); var result = Mapper.Map(trackedDALEntity); if (entity.Categories == null) { return(result); } foreach (var categoryId in entity !.Categories) { var itemCategory = new ItemCategory { ItemId = entity.Id, CategoryId = categoryId }; UOW.ItemCategories.Add(itemCategory); } return(result); }
public string Edit(EventData objEventData) { string msg; try { if (ModelState.IsValid) { using (UOW uow = new UOW()) { uow._iEventsDataRepository.Update(objEventData); uow.SaveChanges(); } msg = "Saved Successfully"; } else { msg = "Validation data not successfull"; } } catch (Exception ex) { msg = "Error occured:" + ex.Message; } return(msg); }
public WSResponse <List <Indicado> > Listar(Indicado.StatusLead?status = null, int page = 0) { var resp = new WSResponse <List <Indicado> >(); try { //TODO: Trocar para paginação var codUser = Convert.ToInt32(User.Identity.Name); var u = new UOW(); if (status == null) { resp.Content = u.IndicadoRep.Get(i => i.CodParceiro == codUser, page: page, orderBy: indicados => indicados.OrderBy(i => i.CodParceiro)).ToList(); } else { resp.Content = u.IndicadoRep.Get(i => i.Status == status.Value && i.CodParceiro == codUser, page: page, orderBy: indicados => indicados.OrderBy(i => i.CodParceiro)).ToList(); } resp.Success = true; return(resp); } catch (Exception e) { return(resp); } }
public async Task <bool> AddLetterBagToShipment(Guid shipmentId, LetterBag letterBagData, bool noTracking = true) { var bag = UOW.Bags.Add(new Bag() { }); await UOW.SaveChangesAsync(); var letterBag = Repository.Add(new DAL.App.DTO.LetterBag { BagId = bag.Id, Count = letterBagData.Count, Weight = letterBagData.Weight, Price = letterBagData.Price }); await UOW.SaveChangesAsync(); var sp = UOW.ShipmentBags.Add(new ShipmentBag { ShipmentId = shipmentId, BagId = bag.Id, }); await UOW.SaveChangesAsync(); return(true); }
public ActionResult Edit([Bind(Prefix = "Payment")] Payment payment) { Payment dbPayment = UOW.Payments.GetById(payment.Id); if (dbPayment != null) { dbPayment.Amount = payment.Amount; dbPayment.PaymentType = payment.PaymentType; dbPayment.PaymentDate = payment.PaymentDate; dbPayment.AccountId = payment.AccountId; UOW.Commit(); payment = dbPayment; } else { return(HttpNotFound()); } PaymentVM vm = new PaymentVM { Payment = payment, Accounts = UOW.Accounts.GetAll() }; return(View(vm)); }
public ActionResult Edit([Bind(Prefix = "DesignReview")] DesignReview designReview) { DesignReview dbDesignReview = UOW.DesignReviews.GetById(designReview.Id); if (dbDesignReview != null) { dbDesignReview.Title = designReview.Title; dbDesignReview.Description = designReview.Description; dbDesignReview.SelectedComment = designReview.SelectedComment; dbDesignReview.AdditionalComment = designReview.AdditionalComment; dbDesignReview.AcceptedDate = designReview.AcceptedDate; dbDesignReview.IsActive = designReview.IsActive; dbDesignReview.ProjectId = designReview.ProjectId; UOW.Commit(); designReview = dbDesignReview; } DesignReviewVM vm = new DesignReviewVM { DesignReview = designReview, Projects = UOW.Projects.GetAll() }; return(View(vm)); }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { }; return uow; }
public async Task TestInsert() { try { Election election = new Election() { Date = new DateTime(2022, 11, 3).Date, StartDateLocal = new DateTime(2022, 11, 1, 8, 0, 0), EndDateLocal = new DateTime(2022, 11, 3, 20, 0, 0), Description = "2022 November Election", Version = "0.0.0.0", AllowUpdates = false }; UOW.BeginTransaction(); Election inserted = await electionService.Insert(UOW, election); UOW.CloseTransaction(); Assert.IsNotNull(inserted); Assert.IsTrue(inserted.Id != Guid.Empty, "Expect inserted Election Id not be empty"); } catch (Exception ex) { Assert.IsNull(ex, "Exception Thrown: " + ex.Message); } }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { move = Constants.sylphNavyMove }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { islandID = islandID, enemyID = enemyID }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { addr = addr, build = build }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, gold = gold }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { isNeedTrashActiveCard = (context.cards.ActiveOpenCard != Card.None), isNeedRefreshStack = context.cards.IsNeedRefreshStack }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, gold = Constants.sellCost }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, gold = gold, random = context.Randomizer.Range(0, context.cards.Stack.Count - 1) }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, enemyID = enemyID, count = (context.players.GetPlayer(enemyID).Philosophers > 0 ? 1 : 0) }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { cell = cell, killNavyCount = context.map.GetNavyCountByCell(cell), killNavyPlayerID = context.map.GetSeaPointOwnerID(cell) }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, islandID = islandID, builds = builds }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, islandID = islandID, creature = CurrrentCard }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { gold = gold, playerID = gold, move = Constants.navyMove }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { UnitOfWork uow = new UOW() { playerID = playerID, enemyID = enemyID, change = change, cell = cell }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { AuctionCM.Bet beatenBet = context.auction.GetBeatenBet(); int currentPlayerID = (beatenBet != null ? beatenBet.playerID : context.auction.GetNextPlayerID()); UnitOfWork uow = new UOW() { currentPlayerID = currentPlayerID }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { card = context.cards.Open[openCardNumber]; UnitOfWork uow = new UOW() { playerID = playerID, card = card, gold = gold }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { Build build = GodToBuild.Get(context.turn.CurrentGod); UnitOfWork uow = new UOW() { playerID = playerID, addr = addr, gold = gold, build = build }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { bool attackRetreat = (playerID == context.navyFight.AttackPlayerID); UnitOfWork uow = new UOW() { playerID = playerID, from = context.navyFight.DefenceCell, to = (attackRetreat ? context.navyFight.AttackCell : to), count = (attackRetreat ? context.armyFight.AttackCount : context.navyFight.DefenceCount), attackRetreat = attackRetreat }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<int> players = new List<int>(); for (int i = 0; i < context.players.PlayersCount; ++i) players.Add(i); List<int> playersOrder = new List<int>(); for (int i = 0; i < context.players.PlayersCount - 1; ++i) { int randomID = context.Randomizer.Range(0, players.Count-1); playersOrder.Add(players[randomID]); players.RemoveAt(randomID); } playersOrder.Add(players[0]); UnitOfWork uow = new UOW() { playersOrder = playersOrder }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { IslandCM island = context.map.Islands[islandID]; builds = new List<SlotAddr>(); for (int i = 0; i < IslandCM.IslandMetroSizeByIslandSize(island.Size); ++i) { SlotAddr addr = SlotAddr.Create(islandID, i); if (island.Slots[i] != Build.None) builds.Add(addr); } UnitOfWork uow = new UOW() { playerID = playerID, islandID = islandID, builds = builds }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { int attackForceRandom = Dice.Roll(context); int deffenceForceRandom = Dice.Roll(context); int attackForce = context.navyFight.AttackForce + attackForceRandom; int defenceForce = context.navyFight.DeffenceForce + deffenceForceRandom; int attackForceChange = (defenceForce >= attackForce ? 1 : 0); int defenceForceChange = (attackForce >= defenceForce ? 1 : 0); UnitOfWork uow = new UOW() { attackForceRandom = attackForceRandom, defenceForceRandom = deffenceForceRandom, attackForceChange = attackForceChange, defenceForceChange = defenceForceChange }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { List<UOW.NavyAction> actions = new List<UOW.NavyAction>(); List<Hex> sea_cells = context.map.GetSeasNearIsland(islandID); for (int i = 0; i < sea_cells.Count; ++i) { Hex sea_cell = sea_cells[i]; int count = context.map.GetNavyCountByCell(sea_cell); if (count > 0) { List<Hex> neighbours = context.map.GetPointNeighbors(sea_cell); Hex to = null; int ownerID = context.map.GetSeaPointOwnerID(sea_cell); for (int t = 0; t < neighbours.Count; ++t) { Hex h = neighbours[t]; if (context.map.IsPointAccessibleForShip(h, ownerID, false)) { to = h; break; } } UOW.NavyAction a = new UOW.NavyAction() { from = sea_cell, ownerID = ownerID, count = count, to = to }; actions.Add(a); } } UnitOfWork uow = new UOW() { playerID = playerID, islandID = islandID, creature = CurrrentCard, actions = actions }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { int attackForceRandom = Dice.Roll(context); int deffenceForceRandom = Dice.Roll(context); int attackForce = context.armyFight.AttackForce + attackForceRandom; int defenceForce = context.armyFight.DeffenceForce + deffenceForceRandom; int attackForceChange = (defenceForce >= attackForce ? 1 : 0); int defenceForceChange = (attackForce >= defenceForce && context.armyFight.DefenceCount > 0 ? 1 : 0); bool killMinotaurus = (attackForce >= defenceForce && context.armyFight.DefenceCount <= 0); UnitOfWork uow = new UOW() { attackForceRandom = attackForceRandom, defenceForceRandom = deffenceForceRandom, attackForceChange = attackForceChange, defenceForceChange = defenceForceChange, killMinotaurus = killMinotaurus }; return uow; }
protected override UnitOfWork GetUnitOfWorkImpl(Context context) { int currentPlayerID = context.turn.GetNextPlayerID(); God currentGod = context.auction.GetCurrentBetForPlayer(currentPlayerID).god; int gold = 0; if (currentGod == God.Appolon) { long islands_count = context.map.GetIslandsByOwner(currentPlayerID).Count; gold = (islands_count <= 1 ? Constants.apolloBigIncome : Constants.apolloSmallIncome); } List<Card> creatures = context.map.GetPlayersCreatures(currentPlayerID); UnitOfWork uow = new UOW() { currentPlayerID = currentPlayerID, currentGod = currentGod, gold = gold, isNeedRefreshStack = context.cards.IsNeedRefreshStack, creatures = creatures }; return uow; }