• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Models.RepositoryDetailModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Bonobo.Git.Server.Models.RepositoryDetailModel的典型用法代码示例。如果您正苦于以下问题:C# RepositoryDetailModel类的具体用法?C# RepositoryDetailModel怎么用?C# RepositoryDetailModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RepositoryDetailModel类属于Bonobo.Git.Server.Models命名空间,在下文中一共展示了RepositoryDetailModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Edit

 public ActionResult Edit(RepositoryDetailModel model)
 {
     if (ModelState.IsValid)
     {
         var currentUserIsInAdminList = model.PostedSelectedAdministrators != null && model.PostedSelectedAdministrators.Contains(User.Id());
         if (currentUserIsInAdminList || User.IsInRole(Definitions.Roles.Administrator))
         {
             var existingRepo = RepositoryRepository.GetRepository(model.Id);
             var repoModel = ConvertRepositoryDetailModel(model);
             MoveRepo(existingRepo, repoModel);
             try
             {
                 RepositoryRepository.Update(repoModel);
             }
             catch (System.Data.Entity.Infrastructure.DbUpdateException)
             {
                 MoveRepo(repoModel, existingRepo);
             }
             ViewBag.UpdateSuccess = true;
         }
         else
         {
             ModelState.AddModelError("Administrators", Resources.Repository_Edit_CantRemoveYourself);
         }
     }
     PopulateCheckboxListData(ref model);
     return View(model);
 }
开发者ID:RedX2501,项目名称:Bonobo-Git-Server,代码行数:28,代码来源:RepositoryController.cs


示例2: Add

        public ActionResult Add(RepositoryDetailModel model)
        {
            if (!User.IsInRole(Definitions.Roles.Administrator) && !UserConfigurationManager.AllowUserRepositoryCreation)
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            if (model != null && !String.IsNullOrEmpty(model.Name))
            {
                model.Name = Regex.Replace(model.Name, @"\s", "");
            }

            if (String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Repository_Add_NameFailure);
            }
            else if (ModelState.IsValid)
            {
                if (RepositoryRepository.Create(ConvertRepositoryDetailModel(model)))
                {
                    string path = Path.Combine(UserConfigurationManager.Repositories, model.Name);
                    if (Directory.Exists(path))
                    {
                        using (GitSharp.Repository repository = new GitSharp.Repository(path))
                        {
                            if (repository.Branches.Count > 0)
                            {
                                TempData["AddSuccess"] = true;
                                return RedirectToAction("Index");
                            }
                            else
                            {
                                RepositoryRepository.Delete(model.Name);
                                ModelState.AddModelError("", Resources.Repository_Add_NoBranches);
                            }
                        }
                    }
                    else
                    {
                        RepositoryRepository.Delete(model.Name);
                        ModelState.AddModelError("", Resources.Repository_Add_DirectoryNotExisting);
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Repository_Create_Failure);
                }
            }
            PopulateEditData();
            return View(model);
        }
开发者ID:tseel,项目名称:Bonobo-Git-Server,代码行数:51,代码来源:RepositoryController.cs


示例3: Clone

        public ActionResult Clone(string id)
        {
            if (!User.IsInRole(Definitions.Roles.Administrator) && !UserConfiguration.Current.AllowUserRepositoryCreation)
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            var model = new RepositoryDetailModel
            {
                Administrators = new[] { User.Identity.Name.ToLowerInvariant() },
            };
            ViewBag.ID = id;
            PopulateEditData();
            return View(model);
        }
开发者ID:nagyistoce,项目名称:Bonobo-Git-Server,代码行数:15,代码来源:RepositoryController.cs


示例4: Edit

 public ActionResult Edit(RepositoryDetailModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Administrators.Contains(User.Id(), StringComparer.OrdinalIgnoreCase))
         {
             RepositoryRepository.Update(ConvertRepositoryDetailModel(model));
             ViewBag.UpdateSuccess = true;
         }
         else
         {
             ModelState.AddModelError("Administrators", Resources.Repository_Edit_CantRemoveYourself);
         }
     }
     PopulateEditData();
     return View(model);
 }
开发者ID:ikarstein,项目名称:Bonobo-Git-Server,代码行数:17,代码来源:RepositoryController.cs


示例5: Edit

 public ActionResult Edit(RepositoryDetailModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.Administrators.Contains(User.Identity.Name.ToLowerInvariant()))
         {
             RepositoryRepository.Update(ConvertRepositoryDetailModel(model));
             ViewBag.UpdateSuccess = true;
         }
         else
         {
             ModelState.AddModelError("Administrators", Resources.Repository_Edit_CantRemoveYourself);
         }
     }
     PopulateEditData();
     return View(model);
 }
开发者ID:hammadrauf,项目名称:Bonobo-Git-Server,代码行数:17,代码来源:RepositoryController.cs


示例6: Create

        public ActionResult Create(RepositoryDetailModel model)
        {
            if (!User.IsInRole(Definitions.Roles.Administrator) && !UserConfiguration.Current.AllowUserRepositoryCreation)
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            if (model != null && !String.IsNullOrEmpty(model.Name))
            {
                model.Name = Regex.Replace(model.Name, @"\s", "");
            }

            if (String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Repository_Create_NameFailure);
            }
            else if (ModelState.IsValid)
            {
                if (RepositoryRepository.Create(ConvertRepositoryDetailModel(model)))
                {
                    string path = Path.Combine(UserConfiguration.Current.Repositories, model.Name);
                    if (!Directory.Exists(path))
                    {
                        LibGit2Sharp.Repository.Init(path, true);
                        TempData["CreateSuccess"] = true;
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        RepositoryRepository.Delete(model.Name);
                        ModelState.AddModelError("", Resources.Repository_Create_DirectoryExists);
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Repository_Create_Failure);
                }
            }
            PopulateEditData();
            return View(model);
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:41,代码来源:RepositoryController.cs


示例7: Clone

        public ActionResult Clone(string id, RepositoryDetailModel model)
        {
            if (!User.IsInRole(Definitions.Roles.Administrator) && !UserConfiguration.Current.AllowUserRepositoryCreation)
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            if (model != null && !String.IsNullOrEmpty(model.Name))
            {
                model.Name = Regex.Replace(model.Name, @"\s", "");
            }

            if (String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Repository_Create_NameFailure);
            }
            else if (ModelState.IsValid)
            {
                if (RepositoryRepository.Create(ConvertRepositoryDetailModel(model)))
                {
                    string targetRepositoryPath = Path.Combine(UserConfiguration.Current.Repositories, model.Name);
                    if (!Directory.Exists(targetRepositoryPath))
                    {
                        string sourceRepositoryPath = Path.Combine(UserConfiguration.Current.Repositories, id);

                        LibGit2Sharp.CloneOptions options = new LibGit2Sharp.CloneOptions()
                            {
                                IsBare = true,
                                Checkout = false
                            };

                        LibGit2Sharp.Repository.Clone(sourceRepositoryPath, targetRepositoryPath, options);
                        TempData["CloneSuccess"] = true;
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        RepositoryRepository.Delete(model.Name);
                        ModelState.AddModelError("", Resources.Repository_Create_DirectoryExists);
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Repository_Create_Failure);
                }
            }

            ViewBag.ID = id;
            PopulateEditData();
            return View(model);
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:51,代码来源:RepositoryController.cs


示例8: ConvertRepositoryDetailModel

 private RepositoryModel ConvertRepositoryDetailModel(RepositoryDetailModel model)
 {
     return model == null ? null : new RepositoryModel
     {
         Name = model.Name,
         Group = model.Group,
         Description = model.Description,
         Users = model.Users,
         Administrators = model.Administrators,
         Teams = model.Teams,
         AnonymousAccess = model.AllowAnonymous,
         AuditPushUser = model.AuditPushUser,
         Logo = model.Logo != null ? model.Logo.BinaryData : null,
         RemoveLogo = model.Logo != null && model.Logo.RemoveLogo
     };
 }
开发者ID:ikarstein,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:RepositoryController.cs


示例9: PopulateCheckboxListData

 private void PopulateCheckboxListData(ref RepositoryDetailModel model)
 {
     model = model.Id != Guid.Empty ? ConvertRepositoryModel(RepositoryRepository.GetRepository(model.Id), User) : model;
     model.AllAdministrators = MembershipService.GetAllUsers().ToArray();
     model.AllUsers = MembershipService.GetAllUsers().ToArray();
     model.AllTeams = TeamRepository.GetAllTeams().ToArray();
     if (model.PostedSelectedUsers != null && model.PostedSelectedUsers.Any())
     {
         model.Users = model.PostedSelectedUsers.Select(x => MembershipService.GetUserModel(x)).ToArray();
     }
     if (model.PostedSelectedTeams != null && model.PostedSelectedTeams.Any())
     {
         model.Teams = model.PostedSelectedTeams.Select(x => TeamRepository.GetTeam(x)).ToArray();
     }
     if (model.PostedSelectedAdministrators != null && model.PostedSelectedAdministrators.Any())
     {
         model.Administrators = model.PostedSelectedAdministrators.Select(x => MembershipService.GetUserModel(x)).ToArray();
     }
     model.PostedSelectedAdministrators =  new Guid[0];
     model.PostedSelectedUsers = new Guid[0];
     model.PostedSelectedTeams = new Guid[0];
 }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:22,代码来源:RepositoryController.cs


示例10: ConvertRepositoryDetailModel

 private RepositoryModel ConvertRepositoryDetailModel(RepositoryDetailModel model)
 {
     return model == null ? null : new RepositoryModel
     {
         Id = model.Id,
         Name = model.Name,
         Group = model.Group,
         Description = model.Description,
         Users = model.PostedSelectedUsers != null ? model.PostedSelectedUsers.Select(x => MembershipService.GetUserModel(x)).ToArray() : new UserModel[0],
         Administrators = model.PostedSelectedAdministrators != null ? model.PostedSelectedAdministrators.Select(x => MembershipService.GetUserModel(x)).ToArray() : new UserModel[0],
         Teams = model.PostedSelectedTeams != null ? model.PostedSelectedTeams.Select(x => TeamRepository.GetTeam(x)).ToArray() : new TeamModel[0],
         AnonymousAccess = model.AllowAnonymous,
         AuditPushUser = model.AuditPushUser,
         Logo = model.Logo != null ? model.Logo.BinaryData : null,
         AllowAnonymousPush = model.AllowAnonymousPush,
         RemoveLogo = model.Logo != null && model.Logo.RemoveLogo,
         LinksUseGlobal = model.LinksUseGlobal,
         LinksRegex = model.LinksRegex ?? "",
         LinksUrl = model.LinksUrl ?? ""
     };
 }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:21,代码来源:RepositoryController.cs


示例11: Create

        public ActionResult Create(RepositoryDetailModel model)
        {
            if (!RepositoryPermissionService.HasCreatePermission(User.Id()))
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            if (model != null && !String.IsNullOrEmpty(model.Name))
            {
                model.Name = Regex.Replace(model.Name, @"\s", "");
            }

            if (model != null && String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Repository_Create_NameFailure);
            }
            else if (ModelState.IsValid)
            {

                var repo_model = ConvertRepositoryDetailModel(model);
                if (RepositoryRepository.Create(repo_model))
                {
                    string path = Path.Combine(UserConfiguration.Current.Repositories, model.Name);
                    if (!Directory.Exists(path))
                    {
                        LibGit2Sharp.Repository.Init(path, true);
                        TempData["CreateSuccess"] = true;
                        TempData["SuccessfullyCreatedRepositoryName"] = model.Name;
                        TempData["SuccessfullyCreatedRepositoryId"] = repo_model.Id;
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        RepositoryRepository.Delete(model.Id);
                        ModelState.AddModelError("", Resources.Repository_Create_DirectoryExists);
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Repository_Create_Failure);
                }
            }
            PopulateCheckboxListData(ref model);
            return View(model);
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:45,代码来源:RepositoryController.cs


示例12: Clone

        public ActionResult Clone(Guid id, RepositoryDetailModel model)
        {
            if (!RepositoryPermissionService.HasCreatePermission(User.Id()))
            {
                return RedirectToAction("Unauthorized", "Home");
            }

            if (model != null && !String.IsNullOrEmpty(model.Name))
            {
                model.Name = Regex.Replace(model.Name, @"\s", "");
            }

            if (model != null && String.IsNullOrEmpty(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Repository_Create_NameFailure);
            }
            else if (ModelState.IsValid)
            {
                var repo_model = ConvertRepositoryDetailModel(model);
                if (RepositoryRepository.Create(repo_model))
                {
                    string targetRepositoryPath = Path.Combine(UserConfiguration.Current.Repositories, model.Name);
                    if (!Directory.Exists(targetRepositoryPath))
                    {
                        var source_repo = RepositoryRepository.GetRepository(id);
                        string sourceRepositoryPath = Path.Combine(UserConfiguration.Current.Repositories, source_repo.Name);

                        LibGit2Sharp.CloneOptions options = new LibGit2Sharp.CloneOptions()
                            {
                                IsBare = true,
                                Checkout = false
                            };

                        LibGit2Sharp.Repository.Clone(sourceRepositoryPath, targetRepositoryPath, options);

                        using (var repo = new LibGit2Sharp.Repository(targetRepositoryPath))
                        {
                            if (repo.Network.Remotes.Any(r => r.Name == "origin"))
                            {
                                repo.Network.Remotes.Remove("origin");
                            }
                        }

                        TempData["CloneSuccess"] = true;
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        RepositoryRepository.Delete(model.Id);
                        ModelState.AddModelError("", Resources.Repository_Create_DirectoryExists);
                    }
                }
                else
                {
                    ModelState.AddModelError("", Resources.Repository_Create_Failure);
                }
            }

            ViewBag.ID = id;
            PopulateCheckboxListData(ref model);
            return View(model);
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:62,代码来源:RepositoryController.cs


示例13: Delete

 public ActionResult Delete(RepositoryDetailModel model)
 {
     if (model != null && !String.IsNullOrEmpty(model.Name))
     {
         string path = Path.Combine(UserConfiguration.Current.Repositories, model.Name);
         if (Directory.Exists(path))
         {
             DeleteFileSystemInfo(new DirectoryInfo(path));
         }
         RepositoryRepository.Delete(model.Name);
         TempData["DeleteSuccess"] = true;
     }
     return RedirectToAction("Index");
 }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:14,代码来源:RepositoryController.cs


示例14: ConvertRepositoryDetailModel

 private RepositoryModel ConvertRepositoryDetailModel(RepositoryDetailModel model)
 {
     return model == null ? null : new RepositoryModel
     {
         Name = model.Name,
         Group = model.Group,
         Description = model.Description,
         Users = model.Users,
         Administrators = model.Administrators,
         Teams = model.Teams,
         AnonymousAccess = model.AllowAnonymous,
         AuditPushUser = model.AuditPushUser,
     };
 }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:14,代码来源:RepositoryController.cs


示例15: SetGitUrls

        /// <summary>
        /// Construct the URLs for the repository
        /// (This code extracted from the view)
        /// </summary>
        void SetGitUrls(RepositoryDetailModel model)
        {
            string serverAddress = System.Configuration.ConfigurationManager.AppSettings["GitServerPath"]
                                   ?? string.Format("{0}://{1}{2}{3}/",
                                       Request.Url.Scheme,
                                       Request.Url.Host,
                                       (Request.Url.IsDefaultPort ? "" : (":" + Request.Url.Port)),
                                       Request.ApplicationPath == "/" ? "" : Request.ApplicationPath
                                       );

            model.GitUrl = String.Concat(serverAddress, model.Name, ".git");
            if (User.Identity.IsAuthenticated)
            {
                model.PersonalGitUrl =
                    String.Concat(serverAddress.Replace("://", "://" + Uri.EscapeDataString(User.Username()) + "@"), model.Name, ".git");
            }
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:21,代码来源:RepositoryController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compiler.CompilerContext类代码示例发布时间:2022-05-24
下一篇:
C# Data.BonoboGitServerContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap