public async Task Register(string role, string millitaryRank, string firstName, string lastName, string email, string phoneNumber, string pesel, string postCode, string city, string street, string houseNumber, string password) { if (await IfExistTask(email, pesel)) { throw new Exception("User already exist"); } var hmac = new HMACSHA512(); switch (role) { case "Soldier": var soldierToCreate = new Soldier(Guid.NewGuid(), hmac.ComputeHash(Encoding.UTF8.GetBytes(password)), hmac.Key, role, millitaryRank, firstName, lastName, email, phoneNumber, pesel, postCode, city, street, houseNumber); await _soldierRepository.AddSoldier(soldierToCreate); break; case "Commander": var commanderToCreate = new Commander(Guid.NewGuid(), hmac.ComputeHash(Encoding.UTF8.GetBytes(password)), hmac.Key, role, millitaryRank, firstName, lastName, email, phoneNumber, pesel, postCode, city, street, houseNumber); await _commanderRepository.AddCommander(commanderToCreate); break; case "Admin": var adminToCreate = new Admin(Guid.NewGuid(), hmac.ComputeHash(Encoding.UTF8.GetBytes(password)), hmac.Key, role, millitaryRank, firstName, lastName, email, phoneNumber, pesel, postCode, city, street, houseNumber); await _adminRepository.AddAdmin(adminToCreate); break; default: throw new Exception("Something went wrong"); } }