public Role Update(Role role) { using (var ctx = new WcfEntityContext()) { ctx.AttachModify("Roles", role); ctx.SaveChanges(); return role; } }
public Role Create(Role role) { using (var ctx = new WcfEntityContext()) { ctx.Roles.AddObject(role); ctx.SaveChanges(); return role; } }
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(); } }
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); }