Exemplo n.º 1
0
        public Boolean UserHasAccessToProject(ApplicationUser user, Project wk, Boolean isDelete)
        {
            try
            {
                Boolean ap = false;
                if (user != null && UserExists(user.UserName.ToString()) == true)
                {
                    if (isDelete == true)
                    {
                        IdentityRole role = this.GetRole(AdminRoles);
                        if (role != null)
                        {
                            if (role.Users.First(x => x.UserId == user.Id) != null && wk.Admininstrator== user.Id)
                            {
                                ap = true;
                            }

                        }
                    }
                    else
                    {
                        if (wk.Admininstrator == user.Id)
                        {
                            ap = true;
                        }
                    }
                }

                return ap;

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return false;
            }
        }
Exemplo n.º 2
0
        public Project ExportToModel()
        {
            try
            {
                Project ap = new Project();

                ap.Id = Id;
                ap.Bugs = Bugs;
                ap.ChangeLogs = ChangeLogs;
                ap.Name = Name;
                ap.News = News;
                ap.Releases = Releases;
                ap.RowVersion = RowVersion;
                ap.WikiName = WikiName;

                ap.Description = Description;
                if (Admininstrator != null)
                {
                    ap.Admininstrator = Admininstrator.Id;
                }
                if (Members != null)
                {
                    ap.Members = new List<ProjectMember>();
                    foreach (var m in this.Members)
                    {
                        ProjectMember mem = new ProjectMember();
                        mem.Member = m.Id;
                        mem.Project = ap;
                        ap.Members.Add(mem);

                    }

                }
                return ap;
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;

            }
        }
Exemplo n.º 3
0
        public void Create(Project project,string  user)
        {
            try
            {
                if (usrmng == null)
                {
                    usrmng = new ProjectUserManager();
                }

                if (project != null && CommonTools.isEmpty(user) == false
                   && usrmng.UserExists(user) == true)
                {

                    ApplicationUser admin = usrmng.GetUser(user);
                    if (admin != null)
                    {

                        Wiki wk = new Wiki();
                        wk.Name = project.Name;
                        wk.WikiTitle = project.Name;
                        wk.Administrator = admin.Id;
                        wk.Moderators = new List<WikiMods>();
                        WikiMods wkm = new WikiMods();
                        wkm.Moderator = admin.Id;
                        wkm.Wiki = wk;
                        wk.Moderators.Add(wkm);
                        wkmngr.CreateWiki(wk,user);

                        //project.Admininstrator = admin;
                        //project.AdmininstratorId = admin.Id;
                        ApplicationUser owner = new ApplicationUser();

                        //owner.Claims = admin.Claims;
                        owner = admin.Clone();

                        project.WikiName = project.Name;
                       project.News = new List<ProjectNews>();
                        //List<FileReleases> filelst= new List<FileReleases>();
                        //project.Releases = filelst;
                        project.Members = new List<ProjectMember>();
                        if (db == null)
                        {
                            db = new ApplicationDbContext();
                        }
                        //ProjectUser projusr = new ProjectUser();
                        //   project.Admininstrator = owner;

                       project.Admininstrator = admin.Id;
                       //   db.Configuration.ValidateOnSaveEnabled = false;
                       // db.Configuration.LazyLoadingEnabled = true;
                        //Statics.usersprojmngr.AddNewProjectToUser(admin, project);
                        db.Projects.Add(project);

                        db.SaveChanges();
                        string plugrelpath= plugmanger.GetPluginFilesRelativeDir("Projects");
                        string path = Path.Combine(plugrelpath, project.Name);
                        FileManager.CreateDirectory(path);

                    }
                }

            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);

            }
        }
Exemplo n.º 4
0
        public void ImportFromModel(Project md)
        {
            try
            {
                if (md != null && CommonTools.isEmpty(md.Admininstrator) == false
                    )
                {
                    ApplicationUser user = CommonTools.usrmng.GetUserbyID(md.Admininstrator);

                    if (user != null)
                    {
                        this.Id = md.Id;
                        this.Bugs = md.Bugs;
                        this.ChangeLogs = md.ChangeLogs;
                        this.Name = md.Name;
                        this.News = md.News;
                        this.Releases = md.Releases;
                        this.RowVersion = md.RowVersion;
                        this.WikiName = md.WikiName;

                        this.Description = md.Description;
                        this.Admininstrator = user;
                        if (md.Members != null)
                        {
                            List<ApplicationUser> mem = new List<ApplicationUser>();
                            foreach (var m in md.Members)
                            {
                                ApplicationUser ms = CommonTools.usrmng.GetUserbyID(m.Member);
                                if (ms != null)
                                {
                                    mem.Add(ms);

                                }

                            }
                            this.Members = mem;
                        }

                    }
                }
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }
Exemplo n.º 5
0
        public void Edit(Project project)
        {
            try
            {
                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                CommonTools.ErrorReporting(ex);

            }
        }