本文整理汇总了C#中ISession.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.Update方法的具体用法?C# ISession.Update怎么用?C# ISession.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeDescription
public virtual void ChangeDescription(string description, ISession session)
{
if ((this.TribePermission & TribePermission.DiplomateOfficer) == 0)
return;
this.Group.Description = description;
session.Update(this.Group);
}
示例2: ChangeCommitted
internal static bool ChangeCommitted(this ISessionPersistentObject al,CRUD Operation, IImportContext iic, ISession session)
{
if (al == null)
throw new Exception("Algo Error");
bool needtoregister = false;
IObjectStateCycle oa = al;
switch (Operation)
{
case CRUD.Created:
needtoregister = true;
session.Save(al);
break;
case CRUD.Update:
session.Update(al);
oa.HasBeenUpdated();
break;
case CRUD.Delete:
session.Delete(al);
oa.SetInternalState(ObjectState.Removed,iic);
break;
}
al.Context = null;
return needtoregister;
}
示例3: Populate
private void Populate(ISession session)
{
Assert.IsNotNull(session);
session.BeginTransaction();
try
{
var person = new Person
{
FirstName = "brady",
LastName = "gaster"
};
session.Save(person);
Assert.Greater(person.Id, 0);
int newPersonId = person.Id;
person.FirstName = "Gina";
session.Update(person);
Assert.Greater(person.Id, 0);
Assert.IsTrue(person.Id == newPersonId);
session.Transaction.Commit();
}
catch
{
session.Transaction.Rollback();
}
}
示例4: DismissPlayer
public virtual void DismissPlayer(Player player, ISession session)
{
if (player.Group == this.Group || ((this.TribePermission & TribePermission.DismissPlayer) == TribePermission.DismissPlayer))
return;
player.Group = null;
session.Update(player);
}
示例5: AddMemberToStaffGroup
public void AddMemberToStaffGroup(Player currentStaff, Player member, StaffGroup group, ISession session)
{
ServicesList.SecurityService.CheckPermission(currentStaff, JobEnum.MemberManagement.ToString(), "write");
if (member.StaffGroups.Contains(group))
return;
member.StaffGroups.Add(group);
session.Update(member);
}
示例6: UserService_SaveUser_UpdatesAUser
public void UserService_SaveUser_UpdatesAUser()
{
_session = A.Fake<ISession>();
_userService = new UserService(_session, _siteSettings);
var user = new User();
_userService.SaveUser(user);
A.CallTo(() => _session.Update(user)).MustHaveHappened();
}
示例7: RemoveUrls
private static void RemoveUrls(Webpage webpage, List<UrlHistory> urlsToRemove, ISession session)
{
foreach (UrlHistory history in urlsToRemove)
{
webpage.Urls.Remove(history);
history.Webpage = null;
UrlHistory closureHistory = history;
session.Update(closureHistory);
}
}
示例8: CreateTribe
public virtual void CreateTribe(string tag, string name, ISession session)
{
beans.Group group = new Group();
group.Tag = tag;
group.Name = name;
group.Description = "";
group.Introduction = "";
this.Group = group;
this.TribePermission = TribePermission.Duke;
session.Save(group);
session.Update(this);
}
示例9: DisbandTribe
public virtual void DisbandTribe(ISession session)
{
if (this.Group == null && this.TribePermission != beans.TribePermission.Duke)
return;
foreach (TribeInvite invite in this.Group.Invites)
session.Delete(invite);
foreach (Player member in this.Group.Members)
{
member.Group = null;
session.Update(member);
}
session.Delete(this.Group);
}
示例10: Expire
public virtual void Expire(DateTime time, ISession session)
{
if (time < this.FinishTime)
return;
this.Hero.Owner = this.Owner;
this.Hero.InVillage = this.Owner.MainVillage;
if (this.Owner.MainVillage.MainHero == null)
{
this.Owner.MainVillage.MainHero = this.Hero;
}
Price p = Recruit.GetPrice(TroopType.Nobleman);
this.Owner.MainVillage.Population += p.Population;
this.Owner.MainVillage.Heroes.Add(this.Hero);
session.Update(this.Owner.MainVillage);
this.Hero.IsRecruiting = false;
this.Hero.IsDead = false;
session.Update(this.Hero);
session.Delete(this);
}
示例11: OnSaving
public virtual void OnSaving(ISession session)
{
if (Selected && FormProperty.OnlyOneOptionSelectable)
{
foreach (var option in FormProperty.Options.Except(this))
{
option.Selected = false;
session.Update(option);
}
}
else if (FormProperty.OnlyOneOptionSelectable && !FormProperty.Options.Except(this).Any())
{
Selected = true;
}
}
示例12: ResetScheduledTasks
private void ResetScheduledTasks(ISession session, DateTime now)
{
var hungScheduledTasks = session.QueryOver<ScheduledTask>()
.Where(
task => task.Site.Id == _site.Id &&
(task.Status == TaskExecutionStatus.AwaitingExecution ||
task.Status == TaskExecutionStatus.Executing) &&
(task.LastQueuedAt < now.AddMinutes(-15) || task.LastQueuedAt == null)
)
.List();
foreach (var task in hungScheduledTasks)
{
task.Status = TaskExecutionStatus.Pending;
session.Update(task);
}
}
示例13: Save
public virtual void Save(ISession session)
{
int quantity = this.OfferQuantity * this.OfferNumber;
if (this.AtVillage[this.OfferType] < quantity)
throw new TribalWarsException("Không đủ tài nguyên");
int merchant = (int)Math.Ceiling((double)(this.OfferQuantity / 1000)) * this.OfferNumber;
if (merchant > this.AtVillage.VillageBuildingData.Merchant)
throw new TribalWarsException("Không đủ thương nhân");
this.AtVillage[this.OfferType] -= quantity;
this.AtVillage.VillageBuildingData.Merchant -= merchant;
this.CreateTime = DateTime.Now;
this.AtVillage.Offers.Add(this);
session.Save(this);
session.Update(this.AtVillage);
}
示例14: Effect
public override MovingCommand Effect(ISession session)
{
this.ToVillage.VillageResourceData.Clay += this.Clay;
this.ToVillage.VillageResourceData.Wood += this.Wood;
this.ToVillage.VillageResourceData.Iron += this.Iron;
Return r = new Return();
r.Merchant = this.Merchant;
r.FromVillage = this.ToVillage;
r.ToVillage = this.FromVillage;
r.StartingTime = this.LandingTime;
r.LandingTime = Map.LandingTime(TroopType.Merchant, r.FromVillage, r.ToVillage, r.StartingTime);
SendResourceReport report = new SendResourceReport();
report.Time = this.LandingTime;
report.Title = String.Format("{0} gửi tài nguyên đến {1} ({2}|{3})", this.FromVillage.Player.Username, this.ToVillage.Name, this.ToVillage.X.ToString("000"), this.ToVillage.Y.ToString("000"));
report.Unread = true;
report.Owner = this.ToVillage.Player;
report.Clay = this.Clay;
report.Wood = this.Wood;
report.Iron = this.Iron;
report.FromVillage = this.FromVillage;
report.FromPlayer = this.FromVillage.Player;
report.ToVillage = this.ToVillage;
report.ToPlayer = this.ToVillage.Player;
this.ToVillage.MovingCommandsToMe.Remove(this);
this.ToVillage.MovingCommandsFromMe.Add(r);
this.FromVillage.MovingCommandsFromMe.Remove(this);
this.FromVillage.MovingCommandsToMe.Add(r);
session.Save(r);
session.Delete(this);
session.Update(this.ToVillage);
session.Update(this.FromVillage);
session.Save(report);
return r;
}
示例15: AddUrls
private void AddUrls(Webpage webpage, List<string> urlsToAdd, ISession session)
{
foreach (string item in urlsToAdd)
{
UrlHistory history =
_session.Query<UrlHistory>().FirstOrDefault(urlHistory => urlHistory.UrlSegment == item);
bool isNew = history == null;
if (isNew)
{
history = new UrlHistory {UrlSegment = item, Webpage = webpage};
session.Save(history);
}
else
history.Webpage = webpage;
if (!webpage.Urls.Contains(history))
webpage.Urls.Add(history);
session.Update(history);
}
}