本文整理汇总了C#中BaseController.RollbackTransactionFast方法的典型用法代码示例。如果您正苦于以下问题:C# BaseController.RollbackTransactionFast方法的具体用法?C# BaseController.RollbackTransactionFast怎么用?C# BaseController.RollbackTransactionFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseController
的用法示例。
在下文中一共展示了BaseController.RollbackTransactionFast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public static ActionResult Delete(BaseController controller, int id)
{
if (id == Photo.NoPic)
{
controller.RollbackTransactionFast();
return new HttpBadRequestResult("Cannot delete this photo.");
}
var photo = controller.DatabaseSession.Get<Photo>(id);
if (photo == null)
{
return new HttpNotFoundResult("Photo not found");
}
// This is a hard delete.
controller.DatabaseSession.Execute(@"
UPDATE Person SET PhotoId = 1 WHERE PhotoId = @PhotoId;
UPDATE Show SET PhotoId = 1 WHERE PhotoId = @PhotoId;
DELETE FROM PersonPhoto WHERE PhotoId = @PhotoId;
DELETE FROM ShowPhoto WHERE PhotoId = @PhotoId;
DELETE FROM Photo WHERE PhotoId = @PhotoId;
", new { PhotoId = id });
// TODO: delete blob
return null;
}
示例2: DeleteTag
public static ActionResult DeleteTag(BaseController controller, int id, int? personId = null, int? showId = null)
{
if (id == Photo.NoPic)
{
controller.RollbackTransactionFast();
return new HttpBadRequestResult("Cannot tag this photo.");
}
if (personId.HasValue)
{
// only delete the tag if the photo is not the Person's default photo
controller.DatabaseSession.Execute(
"DELETE FROM PersonPhoto WHERE PhotoId = @PhotoId AND PersonId = @PersonId AND NOT EXISTS (SELECT * FROM Person WHERE PhotoId = @PhotoId AND PersonId = @PersonId)"
, new { PhotoId = id, PersonId = personId.Value });
}
if (showId.HasValue)
{
// only delete the tag if the photo is not the Show's default photo
controller.DatabaseSession.Execute(
"DELETE FROM ShowPhoto WHERE PhotoId = @PhotoId AND ShowId = @ShowId AND NOT EXISTS (SELECT * FROM Show WHERE PhotoId = @PhotoId AND ShowId = @ShowId)"
, new { PhotoId = id, ShowId = showId.Value });
}
return null;
}
示例3: Tag
public static ActionResult Tag(BaseController controller, int id, int? personId = null, int? showId = null)
{
if (id == Photo.NoPic)
{
controller.RollbackTransactionFast();
return new HttpBadRequestResult("Cannot tag this photo.");
}
if (personId.HasValue && !controller.DatabaseSession.Query<PersonPhoto>().Any(x => x.Photo.PhotoId == id && x.Person.PersonId == personId.Value))
{
var personPhoto = new PersonPhoto();
personPhoto.Person = controller.DatabaseSession.Load<Person>(personId.Value);
personPhoto.Photo = controller.DatabaseSession.Load<Photo>(id);
personPhoto.InsertedDateTime = DateTime.UtcNow;
controller.DatabaseSession.Save(personPhoto);
}
if (showId.HasValue && !controller.DatabaseSession.Query<ShowPhoto>().Any(x => x.Photo.PhotoId == id && x.Show.ShowId == showId.Value))
{
var showPhoto = new ShowPhoto();
showPhoto.Show = controller.DatabaseSession.Load<Show>(showId.Value);
showPhoto.Photo = controller.DatabaseSession.Load<Photo>(id);
showPhoto.InsertedDateTime = DateTime.UtcNow;
controller.DatabaseSession.Save(showPhoto);
}
return null;
}
示例4: TagPartial
public static ActionResult TagPartial(BaseController controller, int id, string postURL)
{
if (id == Photo.NoPic)
{
controller.RollbackTransactionFast();
return new HttpBadRequestResult("Cannot tag this photo.");
}
var model = new TagPhotoViewModel();
model.POSTUrl = postURL;
model.Shows = controller.DatabaseSession.Query<Show>()
.ToList()
.OrderBy(x => x, ShowComparer.ReverseChronologicalShowComparer)
.Select(x => new KeyValuePair<int, string>(x.ShowId, x.Year + " " + x.DisplayTitle))
.ToList();
model.People = controller.DatabaseSession.Query<Person>()
.ToList()
.OrderBy(x => x.SortableName)
.Select(x => new KeyValuePair<int, string>(x.PersonId, x.Fullname))
.ToList();
return new ViewModelResult(model);
}