internal string GetOrganizationCode() { string generatedCode = ""; int code = randomCode.Next(1000, 10000); generatedCode = "C" + code.ToString(); List <Organization> listOfOrganizationCode = organizationDal.GetAllCode(); if (listOfOrganizationCode != null) { foreach (var organization in listOfOrganizationCode) { if (generatedCode == organization.Code) { return(GetOrganizationCode()); } } } return(generatedCode); }