public UnitOfWork(IHttpContextAccessor httpContextAccessor, IServiceProvider servicesProvider) { _httpContextAccessor = httpContextAccessor; _servicesProvider = servicesProvider; if (_httpContextAccessor.HttpContext != null) { _contextManager = _servicesProvider.GetService <ContextManager>(); /* only with Ninject */ _context = _contextManager.Context; } /// USE SINGLETON (VALIDATE WITH ASYNC) else { int ThreadId = Thread.CurrentThread.ManagedThreadId; SynchronizationContext aaaa = SynchronizationContext.Current; /// VERIFY IF ALREADY EXISTS AN OPENED CONTEXT FOR THE CURRENT OPERATION if (UnitOfWorkContexManager.ContextOpen(ThreadId)) { _context = (FirstContext)UnitOfWorkContexManager.GetContext(ThreadId); isFirst = false; } /// IF NO, THEN CREATE NEW INSTANCE AND OPEN THE TRANSACTION else { _context = new FirstContext(); _context.Database.BeginTransaction(); UnitOfWorkContexManager.AddContext(_context, ThreadId); } } }
public ViewResult ThirdMethod() { // ViewBag.FirstViewBag = "Evs Lahore"; FirstContext db = new FirstContext(); ViewBag.FirstObject = db.FirstClasses.ToList(); return(View()); }
public ViewResult ThirdMethod(FirstClass obj) { //ViewBag.FirstObject = obj; try { FirstContext db = new FirstContext(); db.FirstClasses.Add(obj); db.SaveChanges(); ViewBag.Message = "Successfully Added"; } catch (Exception e) { ViewBag.Message = $"Something Went Wrong Details {e.Message}"; return(View()); } return(View()); }
/// <summary> /// The test first. /// </summary> private static void TestFirst() { FirstContext firstContext = new FirstContext(); // Usually a tree ArrayList arrayList = new ArrayList { new TerminalExpression(), new NonTerminalExpression(), new TerminalExpression(), new TerminalExpression() }; // Populate 'abstract syntax tree' // Interpret foreach (AbstractExpression abstractExpression in arrayList) { abstractExpression.Interpret(firstContext); } // Wait for user Console.ReadKey(); }
protected RepositoryAppUser(FirstContext context) { Db = context; }
protected Repository(FirstContext context) { Db = context; }
public CopiaDeDiplomaReportadosModel(FirstContext context) { _context = context; }
/// <summary> /// The interpret. /// </summary> /// <param name="context"> /// The context. /// </param> public abstract void Interpret(FirstContext context);
public FirstServices(FirstContext context) { _context = context; }
public PlanillaContribucionReportadosModel(FirstContext context) { this._context = context; }
public HomeController(FirstContext Context) { _Context = Context; }
public FormModel(FirstContext context) { _context = context; }
public planillaContribucion(FirstContext context) { _context = context; }
public DiferimientoReportadosModel(FirstContext context) { _context = context; }
public AppUserRepository(FirstContext context) : base(context) { }
public IndexModel(FirstContext context) { _context = context; }
/// <summary> /// The interpret. /// </summary> /// <param name="context"> /// The context. /// </param> public override void Interpret(FirstContext context) { Console.WriteLine("Called Terminal.Interpret()"); }
public loginPage(FirstContext context) { _context = context; }
public CopiaDeDiploma(FirstContext context) { _context = context; }
public Diferimiento(FirstContext context) { _context = context; }