public Book CreateBook(BookInfo bookInfo) { using (var context = _contextManager.GetContext()) { var book = new Book(bookInfo); context.Add(book); context.SaveChanges(); return(book); } }
public BankAccount CreateBankAccount(string customer, string accountNumber) { using (var context = _contextManager.GetContext()) { var bankAccount = new BankAccount(customer, accountNumber); context.Add(bankAccount); context.SaveChanges(); return(bankAccount); } }
public Note CreateNote(string title) { using (var context = _contextManager.GetContext()) { var note = new Note(title); context.Add(note); context.SaveChanges(); return(note); } }
public Order CreateOrder(string customer) { using (var context = _contextManager.GetContext()) { var order = new Order(customer); context.Add(order); context.SaveChanges(); return(order); } }
public Note CreateNote(Guid bookId, string title) { using (var context = _contextManager.GetContext()) { var book = context.Load <NoteBook>(bookId); var note = new Note(book, title); context.Add(note); context.SaveChanges(); return(note); } }
private TAggregateRoot InternalGetAggregateRoot <TAggregateRoot>(object id) where TAggregateRoot : AggregateRoot { using (var context = _contextManager.GetContext()) { return(context.Load <TAggregateRoot>(id)); } }
//Creates new context containing the new value and the old ones from the proxy public static IDictionary <string, string> UpdateContext(IClientChannel innerChannel, string key, string value) { IContextManager contextManager = innerChannel.GetProperty <IContextManager>(); IDictionary <string, string> context = new Dictionary <string, string>(contextManager.GetContext()); context[key] = value; return(context); }
static public IDictionary <string, string> ExtractContextFromChannel(IClientChannel channel) { // extract context from channel IContextManager cm = channel.GetProperty <IContextManager>(); if ((cm != null) && (cm.Enabled)) { // attempt to extract context from channel return(cm.GetContext()); } return(null); }
public User Create(string name) { using (var context = _contextManager.GetContext()) { var user = new User(name); context.Add(user); context.SaveChanges(); return(user); } }
public Thread Create(string subject, string body, Guid forumId, Guid authorId, int marks) { using (var context = _contextManager.GetContext()) { var forum = context.Load <Forum>(forumId); var author = context.Load <User>(authorId); var thread = new Thread(subject, body, forum, author, marks); context.Add(thread); context.SaveChanges(); return(thread); } }
public Forum Create(string name) { using (var context = _contextManager.GetContext()) { var forum = new Forum(name); context.Add(forum); context.SaveChanges(); return(forum); } }
public Product Create(string name, string description, double price) { using (var context = _contextManager.GetContext()) { var product = new Product(name, description, price); context.Add(product); context.SaveChanges(); return(product); } }
public LibraryAccount Create(string number, string owner) { using (var context = _contextManager.GetContext()) { var account = new LibraryAccount(number, owner); context.Add(account); context.SaveChanges(); return(account); } }
public NoteBook CreateBook(string title) { using (var context = _contextManager.GetContext()) { var book = new NoteBook(title); context.Add(book); context.SaveChanges(); return(book); } }
public Library Create(string name) { using (var context = _contextManager.GetContext()) { var library = new Library(name); context.Add(library); context.SaveChanges(); return(library); } }
public Post Create(string body, Guid threadId, Guid authorId) { using (var context = _contextManager.GetContext()) { var thread = context.Load <Thread>(threadId); var author = context.Load <User>(authorId); var post = new Post(body, thread, author); context.Add(post); context.SaveChanges(); return(post); } }
private BotContext GetValidContext(string userId) { ContextInfo ci = cManager.GetContext(userId); if (ci == null) { return(null); } DateTime currentTime = DateTime.Now; if (currentTime.Subtract(ci.lastUpdatedTime).TotalMinutes > 480) // 8 hours { return(null); } else { if (ci.type == ContextType.PSAContext) { PSAContext psaContext = JsonConvert.DeserializeObject <PSAContext>(ci.jsonString); if (IsValid(psaContext)) { return(psaContext); } else { return(null); } } else if (ci.type == ContextType.ExamSuitContext) { ExamSuitContext esContext = JsonConvert.DeserializeObject <ExamSuitContext>(ci.jsonString); return(esContext); } else if (ci.type == ContextType.ScoreContext) { ScoreContext scContext = JsonConvert.DeserializeObject <ScoreContext>(ci.jsonString); return(scContext); } else { TaskFlowContext tfContext = JsonConvert.DeserializeObject <TaskFlowContext>(ci.jsonString); return(tfContext); } } }
public static void RunTestRemoveAndCheckoutItems() { PermissiveCertificatePolicy.Enact("CN=HTTPS-Server"); Console.Write("Initializing Sales Proxy..."); BicycleWorldSalesServiceClient proxy = new BicycleWorldSalesServiceClient("wsHttpBinding_BicycleWorldSalesService"); Console.WriteLine(" done"); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; // Test the operations in the service try { //Console.WriteLine(proxy.Login()); Console.WriteLine("Press ENTER to start shopping cart"); Console.ReadLine(); TransactionOptions transactionOptions = new TransactionOptions(); transactionOptions.IsolationLevel = IsolationLevel.RepeatableRead; transactionOptions.Timeout = new TimeSpan(0, 1, 0); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions)) { IDictionary <string, string> context = null; IContextManager contextManager = proxy.InnerChannel.GetProperty <IContextManager>(); if (context != null) { contextManager.SetContext(context); } proxy.AddItemToCart("BK-M18B-42"); if (context == null) { context = contextManager.GetContext(); } Console.WriteLine(proxy.GetShoppingCart()); proxy.RemoveItemFromCart("BK-R19B-44"); Console.WriteLine(proxy.GetShoppingCart()); if (proxy.Checkout()) { scope.Complete(); Console.WriteLine("Goods purchased."); } } Console.WriteLine(); // Disconnect from the service proxy.Close(); } catch (FaultException <SystemFault> sf) { Console.WriteLine("SystemFault {0}: {1}\n{2}", sf.Detail.SystemOperation, sf.Detail.SystemMessage, sf.Detail.SystemReason); } catch (FaultException <DatabaseFault> dbf) { Console.WriteLine("DatabaseFault {0}: {1}\n{2}", dbf.Detail.DbOperation, dbf.Detail.DbMessage, dbf.Detail.DbReason); } catch (FaultException e) { Console.WriteLine("{0}: {1}", e.Code.Name, e.Reason); } catch (Exception e) { Console.WriteLine("General exception: {0}", e.Message); Console.WriteLine("Inner Exception: {0}", e.InnerException); } Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); }
public UnitOfWork(IContextManager contextManager) { this.dbContext = contextManager.GetContext(); validationResult = new ValidationResult(); }
public UnitOfWork() { _contextManager = ServiceLocator.Current.GetInstance <IContextManager <TContext> >(); _dbContext = _contextManager.GetContext(); }
public BaseRepository(IContextManager contextManager) { this.contextManager = contextManager; this.Context = contextManager.GetContext(); this.DbSet = Context.Set <TEntity>(); }
protected Repository(IContextManager <TContext> contextManager) { Context = contextManager.GetContext(); DbSet = Context.Set <TEntity>(); }
public UnitOfWork(IContextManager <TContext> contextManager) { _contextManager = contextManager; _dbContext = _contextManager.GetContext(); }
public UnitOfWork(IContextManager contextManager) { _dbContext = contextManager.GetContext(); }
//TODO: Resolver como a DI do ContextManager sera passada public EFRepositoryBase(IContextManager contextManager) { _contextManager = contextManager; _dbContext = _contextManager.GetContext(); _dbSet = _dbContext.Set <TEntity>(); }
public UnitOfWork(IContextManager contextManager) { this.contextManager = contextManager; dbContext = contextManager.GetContext(); }