本文整理汇总了C#中IDocumentSession.CreateRoom方法的典型用法代码示例。如果您正苦于以下问题:C# IDocumentSession.CreateRoom方法的具体用法?C# IDocumentSession.CreateRoom怎么用?C# IDocumentSession.CreateRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDocumentSession
的用法示例。
在下文中一共展示了IDocumentSession.CreateRoom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostRoom
static object PostRoom(
NancyContext context,
IDocumentSession documentSession,
string title,
string slug,
string description)
{
context.Ensure("context");
documentSession.Ensure("documentSession");
if (!context.IsSignedUp())
return 403;
var errors = new List<string>();
errors.AddRange(fn.ValidateRequired("Title", title));
errors.AddRange(fn.ValidateLength("Title", title, 128));
errors.AddRange(fn.ValidateRequired("Slug", slug));
errors.AddRange(fn.ValidateLength("Slug", slug, 128));
errors.AddRange(fn.ValidateFormat("Slug", slug, new Regex("[a-z][a-z0-9_-]+")));
if (description != null)
errors.AddRange(fn.ValidateLength("Description", description, 1024));
var existingRoom =documentSession.GetRoomBySlug(slug);
if (existingRoom != null)
errors.Add(Strings.NotAvailable("slug", slug));
existingRoom = documentSession.GetRoomByTitle(title);
if (existingRoom != null)
errors.Add(Strings.NotAvailable("title", title));
if (errors.Count > 0)
return context.ModelWithStatus(new CreateRoomFormResponse(title, slug, description, errors), 400);
var currentMember = context.GetCurrentMember(documentSession);
Debug.Assert(currentMember != null, "`IsSignedUp` should ensure current member is not null.");
var room = documentSession.CreateRoom(currentMember.Id, slug, title, description);
return context.Redirect(Paths.Room(room.Slug));
}