I'm trying to access an Internal Method in a sealed class but since it is a sealed class, I'm not able to inherit the Internal Method. The backend portion of the solution I'm working on is designed like that.
I found a work around for this which uses an extension of the class
public static class LocalizationsManagerExtension
{
public static string AddAppUserBasic(this LocalizationsManager objDotnet, AppUser newUser, string pword)
{
try
{
objDotnet.AddAppUserBasic(newUser, pword);
return "Success!";
}
catch(Exception ex)
{
return ex.Message;
}
//return IdentityResult.Success;
//return System.Threading.Tasks.Task.Run();
//return "Welcome to the World of DotNet....Mr. " + password;
}
}
public ActionResult UserAddNew(UserAddNewModel model)
{
if (ModelState.IsValid)
{
var user = new DataAccess.AppUser();
user.Name = model.username;
user.Password = model.password;
user.DeveloperRole = model.isDeveloperRole;
user.AdministratorRole = model.isAdministratorRole;
user.TranslatorRole = model.isTranslatorRole;
user.IsDomainUser = model.IsDomainUser;
user.ManagerRole = model.isManagerRole;
user.State = Data.Framework.Repository.Helpers.ObjectState.Added;
var result = LM.AddAppUserBasic(user, user.Password);
if (result == "Success!")
{
ViewBag.ReturnUrl = "/Usermanagement/UserLogin";
//return RedirectToAction("UserLogin", "UserManagement");
}
else { }
}
// If we got this far, something failed, redisplay form
return View(model);
}
I tried this but no luck. I'm able to call "AddAppUserBasic" in another method that I'm calling but it is calling the local method. Not the one in the sealed class.