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


C# IIdGenerator.NextGuid方法代码示例

本文整理汇总了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("/");
            };
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:31,代码来源:SetupModule.cs

示例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;
            };
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:58,代码来源:AdminModule.cs

示例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;
            };
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:41,代码来源:ClientModule.cs

示例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;
            };
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:71,代码来源:ProjectModule.cs

示例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;
            };
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:85,代码来源:TimeRegistrationModule.cs


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