public void MapToRoleRepo(Models.Role role) { this.Role = new RoleRepository() { Name = role.Name, Id = role.Id }; }
private void save(Models.Role Role, bool isUpdate = false) { if (!isUpdate) { this.context.Roles.Add(Role); } this.context.SaveChanges(); }
public void Update(long id, RoleRepository roleRepository) { Models.Role oldRole = this.roleQueryRepository.Find(id); if (oldRole == null) { return; } oldRole.Name = roleRepository.Name; this.save(oldRole, true); }
public RoleRepository FindByName(string name) { Models.Role role = this.context.Roles.Where(role => role.Name == name).FirstOrDefault(); if (role == null) { return(new RoleRepository()); } this.roleRepository.Id = role.Id; this.roleRepository.Name = role.Name; return(this.roleRepository); }
public RoleRepository FindById(long id = 0) { Models.Role role = this.Find(id); if (role == null) { return(new RoleRepository()); } this.roleRepository.Id = role.Id; this.roleRepository.Name = role.Name; return(this.roleRepository); }
public void Delete(long id) { Models.Role role = this.context.Roles.Where(role => role.Id == id).FirstOrDefault(); this.context.Roles.Remove(role); this.context.SaveChanges(); }
public void Create(RoleRepository roleRepository) { Models.Role newRole = new Models.Role(); newRole.Name = roleRepository.Name; this.save(newRole); }