repository-pattern

User roles and authorization

陌路散爱 提交于 2020-02-07 12:25:31
问题 So I want to create a login page where when you enter your login credentials as a admin you get acces. If you are not a admin you get redirected back to the login page. In my database I have a field of boolean type: isAdmin <--datatype(byte") So how can you the best way do this?! I would like to do this in the repository pattern way as it gets easier to unit test it then. I have googled this a lot and starting to get a bit confused on the matter. How many classes, models etc should I have?! I

How can I activate a Service outside Activity correctly?

北城以北 提交于 2020-02-01 07:46:26
问题 I am trying to build an app that will rely on a Webservice to work. To make it, I decided to follow the Model-View-ViewModel architecture together with the Repository pattern. I try to make this architecture inspired by the guidelines shown in Guide to App architecture, from Android Developer's Official Site. I use OkHttp library to consume the WebService, and Room for the phone's database. I made some testing to see if the app obtained succesfully the Data through the Webservice, from inside

How can I activate a Service outside Activity correctly?

眉间皱痕 提交于 2020-02-01 07:46:19
问题 I am trying to build an app that will rely on a Webservice to work. To make it, I decided to follow the Model-View-ViewModel architecture together with the Repository pattern. I try to make this architecture inspired by the guidelines shown in Guide to App architecture, from Android Developer's Official Site. I use OkHttp library to consume the WebService, and Room for the phone's database. I made some testing to see if the app obtained succesfully the Data through the Webservice, from inside

Why the database data is not being updated but object did and without error?

﹥>﹥吖頭↗ 提交于 2020-01-23 06:52:00
问题 I have this bank ATM mock-up app which implements some Domain-Driven Design architecture and Unit of Work pattern. This app have 3 basic functions: Check balance Deposit Withdraw These are the project layers: ATM.Model (Domain model entity layer) namespace ATM.Model { public class BankAccount { public int Id { get; set; } public string AccountName { get; set; } public decimal Balance { get; set; } public decimal CheckBalance() { return Balance; } public void Deposit(int amount) { // Domain

Why the database data is not being updated but object did and without error?

风格不统一 提交于 2020-01-23 06:51:28
问题 I have this bank ATM mock-up app which implements some Domain-Driven Design architecture and Unit of Work pattern. This app have 3 basic functions: Check balance Deposit Withdraw These are the project layers: ATM.Model (Domain model entity layer) namespace ATM.Model { public class BankAccount { public int Id { get; set; } public string AccountName { get; set; } public decimal Balance { get; set; } public decimal CheckBalance() { return Balance; } public void Deposit(int amount) { // Domain

Repository pattern with MongoDB - multiple units of work with one transaction

℡╲_俬逩灬. 提交于 2020-01-23 05:28:15
问题 I'm implementing a DAL abstraction layer on top of the C# Mongo DB driver using the Repository + Unit of Work pattern. My current design is that every unit of work instance opens (and closes) a new Mongo DB session. The problem is that Mongo DB only allows a 1:1 ratio between a session and a transaction, so multiple units of work under the same .NET transaction will not be possible. The current implementation is: public class MongoUnitOfWork { private IClientSessionHandle _sessionHandle;

ASP.Net vNext DbContext Dependency Injection multiple request issues.

拟墨画扇 提交于 2020-01-17 05:54:38
问题 I am attempting to use ASP.Net vNext, MVC, EF7, and the repository pattern (not the issue here, I don't think)... The issue I'm having is that when multiple requests are made against the database, I'm getting the following error: "There is already an open DataReader associated with this Command which must be closed first." Here's some code: public class Startup { public IConfiguration Configuration { get; set; } public Startup(IHostingEnvironment env) { Configuration = new Configuration()

where doese breeze fits into ntier architecture

家住魔仙堡 提交于 2020-01-17 03:53:25
问题 i am Trying to fit in breezeJS with my existing architecture. I have a structure like html/JS/Angular :: based view using hot-towel angular. web api controllers :: whom the view calls. Services layer :: that is being called from Web api. Any business logic goes here. Unit of Work :: And (if) business logic requires to talk to data base for CRUDs it calls UOW. Repository Pattern :: UOW is actually wrapping repositories. and repositores in turn talking to DbContexts. Uptill now i was able to

Generic access to DbContext

两盒软妹~` 提交于 2020-01-14 08:02:26
问题 ObjectContext allows generic access to the generated Entities. DbContext appears to have no such support. Accessing EF5 with a generic repository is challenging. Let's say I want a generic mechanism to read any given entity, call it TEntity: public class DataRepositoryEF5<T> where T: DbContext { private ObjectContext _context; public DataRepositoryEF5(DbContext context) { _context = ((IObjectContextAdapter)context).ObjectContext; } public IEnumerable<TEntity> ReadAll<TEntity>() where TEntity

Fetching Strategy example in repository pattern with pure POCO Entity framework

北城以北 提交于 2020-01-13 06:52:29
问题 I'm trying to roll out a strategy pattern with entity framework and the repository pattern using a simple example such as User and Post in which a user has many posts. From this answer here, I have the following domain: public interface IUser { public Guid UserId { get; set; } public string UserName { get; set; } public IEnumerable<Post> Posts { get; set; } } Add interfaces to support the roles in which you will use the user. public interface IAddPostsToUser : IUser { public void AddPost(Post