示例#1
0
        public Role Update(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.AttachModify("Roles", role);
                ctx.SaveChanges();

                return role;
            }
        }
示例#2
0
        public Role Create(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                ctx.Roles.AddObject(role);
                ctx.SaveChanges();

                return role;
            }
        }
示例#3
0
        public void Delete(Role role)
        {
            using (var ctx = new WcfEntityContext())
            {
                Role myrole = ctx.Roles.Where(p => p.Id == role.Id).FirstOrDefault();
                ctx.Roles.Attach(myrole);
                ctx.Roles.DeleteObject(myrole);

                ctx.SaveChanges();
            }
        }
示例#4
0
        public void RequestProjectAssignment(String code, User user, Role role)
        {
            Project proj = new ProjectRepository().GetAll().Where(p => p.Code == code).SingleOrDefault();

            if (proj == null)
                throw new FaultException("A project with this code does not exist.");

            var existingRequest = new UserProjectSignupRepository().GetAll().Where(
                p => p.ProjectId == proj.Id && p.UserId == user.Id).SingleOrDefault();

            if (existingRequest != null)
            {
                new UserProjectSignupRepository().Delete(existingRequest);
            }

            UserProjectSignup ass = new UserProjectSignup { ProjectId = proj.Id, UserId = user.Id, RoleId = role.Id };

            new UserProjectSignupRepository().Create(ass);
        }