本文整理汇总了C#中IIdGenerator.NextGuid方法的典型用法代码示例。如果您正苦于以下问题:C# IIdGenerator.NextGuid方法的具体用法?C# IIdGenerator.NextGuid怎么用?C# IIdGenerator.NextGuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIdGenerator
的用法示例。
在下文中一共展示了IIdGenerator.NextGuid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupModule
public SetupModule(IAggregateRootRepository repository,
IAccountRepository accountRepository,
IIdGenerator idGenerator)
:base("/setup")
{
Get["/"] = _ =>
{
if (accountRepository.Count() > 0)
return HttpStatusCode.NotFound;
return View["Index"];
};
Post["/"] = _ =>
{
var model = this.Bind<CreateModel>();
if (accountRepository.Count() > 0)
return HttpStatusCode.NotFound;
var account = new Domain.Account(idGenerator.NextGuid(),
model.Name, model.FirstName, model.LastName, model.Email);
account.ChangePassword(model.Password);
account.MakeAdmin();
repository.Save(account);
return Response.AsRedirect("/");
};
}
示例2: AdminModule
public AdminModule(IAggregateRootRepository repository,
IIdGenerator idGenerator)
: base("/write/admin")
{
this.RequiresAuthentication();
this.RequiresClaims(new[] { "Admin" });
Post["/account/create"] = parameters =>
{
var model = this.Bind<EditableAccount>();
var account = new Domain.Account(idGenerator.NextGuid(),
model.Name, model.FirstName, model.LastName, model.Email);
var password = account.GeneratePassword();
repository.Save(account);
return Json(new
{
Account = new Account(account),
Password = password
});
};
Post["/account/update/{id:guid}"] = parameters =>
{
var model = this.Bind<EditableAccount>();
var account = repository.GetById<Domain.Account>((Guid)parameters.id);
if (account != null)
{
account.ChangeDetails(model.Name, model.FirstName, model.LastName, model.Email);
repository.Save(account);
return Json(new
{
Account = new Account(account)
});
}
return null;
};
Post["/account/{id:guid}/newpassword"] = parameters =>
{
var model = this.Bind<AccountNewPassword>();
var account = repository.GetById<Domain.Account>((Guid)parameters.id);
if (account != null)
{
account.ChangePassword(model.Password);
repository.Save(account);
}
return null;
};
}
示例3: ClientModule
public ClientModule(IAggregateRootRepository repository,
IIdGenerator idGenerator)
:base("/write/client")
{
this.RequiresAuthentication();
Post["/create"] = parameters =>
{
var model = this.Bind<EditableClient>();
var client = new Domain.Client(idGenerator.NextGuid(), model.Name);
repository.Save(client);
return Json(new
{
Client = new Client(client)
});
};
Post["/update/{id:guid}"] = parameters =>
{
var model = this.Bind<EditableClient>();
var client = repository.GetById<Domain.Client>((Guid)parameters.id);
if (client != null)
{
client.ChangeDetails(model.Name);
repository.Save(client);
return Json(new
{
Client = new Client(client)
});
}
return null;
};
}
示例4: ProjectModule
public ProjectModule(IAggregateRootRepository repository,
IIdGenerator idGenerator)
:base("/write/project")
{
this.RequiresAuthentication();
Post["/create"] = parameters =>
{
var model = this.Bind<EditableProject>();
var client = repository.GetById<Domain.Client>(model.ClientId);
var project = new Domain.Project(idGenerator.NextGuid(), model.Name, model.Description, client);
repository.Save(project);
return Json(new
{
Project = new Project(client, project)
});
};
Post["/update/{id:guid}"] = parameters =>
{
var model = this.Bind<EditableProject>();
var project = repository.GetById<Domain.Project>((Guid)parameters.id);
if (project != null)
{
project.ChangeDetails(model.Name, model.Description);
if (model.Hidden)
project.Hide();
else project.Unhide();
repository.Save(project);
var client = repository.GetById<Domain.Client>(project.ClientId);
return Json(new
{
Project = new Project(client, project)
});
}
return null;
};
Post["/updatetasks/{id:guid}"] = parameters =>
{
var model = this.Bind<EditableProjectTasks>();
var project = repository.GetById<Domain.Project>((Guid)parameters.id);
if (project != null)
{
project.ChangeTasks(model.Tasks.Select(t => new Domain.ValueObjects.Task { Name = t.Name, Rate = t.Rate }).ToArray());
repository.Save(project);
var client = repository.GetById<Domain.Client>(project.ClientId);
return Json(new
{
Project = new Project(client, project)
});
}
return null;
};
}
示例5: TimeRegistrationModule
public TimeRegistrationModule(IAggregateRootRepository repository,
IIdGenerator idGenerator)
: base("/write/timeregistration")
{
this.RequiresAuthentication();
Post["/create"] = parameters =>
{
var model = this.Bind<EditableTimeRegistration>();
var client = repository.GetById<Domain.Client>(model.ClientId);
var project = repository.GetById<Domain.Project>(model.ProjectId);
var task = project.FindTask(model.Task);
var date = Date.Parse(model.Date);
var from = Time.Parse(model.From);
var to = Time.Parse(model.To);
var timeRegistration = new Domain.TimeRegistration(idGenerator.NextGuid(),
client, project, task,
model.Description, date, from, to);
if (model.CorrectedIncome.HasValue)
timeRegistration.CorrectIncome(model.CorrectedIncome.Value, model.CorrectedIncomeMessage);
repository.Save(timeRegistration);
return Json(new
{
TimeRegistration = new TimeRegistration(timeRegistration, client, project)
});
};
Post["/update/{id:guid}"] = parameters =>
{
var model = this.Bind<EditableTimeRegistration>();
var timeRegistration = repository.GetById<Domain.TimeRegistration>((Guid)parameters.id);
if (timeRegistration != null)
{
var client = repository.GetById<Domain.Client>(model.ClientId);
var project = repository.GetById<Domain.Project>(model.ProjectId);
var task = project.FindTask(model.Task);
var date = Date.Parse(model.Date);
var from = Time.Parse(model.From);
var to = Time.Parse(model.To);
timeRegistration.ChangeDetails(client, project, task,
model.Description, date, from, to);
if (model.CorrectedIncome.HasValue)
timeRegistration.CorrectIncome(model.CorrectedIncome.Value, model.CorrectedIncomeMessage);
else
timeRegistration.ClearCorrectedIncome();
if (model.RefreshRate)
timeRegistration.RefreshRate(task);
repository.Save(timeRegistration);
return Json(new
{
TimeRegistration = new TimeRegistration(timeRegistration, client, project)
});
}
return null;
};
Post["/delete/{id:guid}"] = parameters =>
{
var timeRegistration = repository.GetById<Domain.TimeRegistration>((Guid)parameters.id);
if (timeRegistration != null)
{
timeRegistration.Delete();
repository.Save(timeRegistration);
}
return null;
};
}