public int AddUser(string username, string password, string name, string family, string role, INewsRepository repository) { try { var user = new User { Family = family, Name = name, UserName = username, Role = role, HashPassword = CryptographyHelper.Encrypt(password), }; repository.AddUser(user); repository.SaveChanges(); return(user.Id); } catch (Exception exp) { return(-1); } }