当前位置: 首页>>代码示例>>C#>>正文


C# BaseController.RollbackTransactionFast方法代码示例

本文整理汇总了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;
        }
开发者ID:jdaigle,项目名称:FriendsOfDT,代码行数:27,代码来源:PhotosController.cs

示例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;
        }
开发者ID:jdaigle,项目名称:FriendsOfDT,代码行数:26,代码来源:PhotosController.cs

示例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;
        }
开发者ID:jdaigle,项目名称:FriendsOfDT,代码行数:27,代码来源:PhotosController.cs

示例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);
        }
开发者ID:jdaigle,项目名称:FriendsOfDT,代码行数:23,代码来源:PhotosController.cs


注:本文中的BaseController.RollbackTransactionFast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。