Skip to main content

Posts

Showing posts from 2016

#AT Repository and Unit of Work Pattern - 7

Presentation project create a WCF service application by right clicking on solution. we will get Service1.svc and IService1.svc. rename the service if required. change the web config. <endpointBehaviors>         <behavior>           <webHttp />         </behavior>       </endpointBehaviors> <services>       <service name="ContactMangWCF.ContactManagerService" behaviorConfiguration=" myBehaviour ">         <endpoint address="" binding="webHttpBinding" contract="ContactMangWCF.IContactManagerService"></endpoint>       </service>     </services> <serviceBehaviors>         <behavior name=" myBehaviour ">           <!-- To avoid disclosing metadata information, set the values below to false before deployment...

#AT Repository and Unit of Work Pattern - 6

we are going to see service file below, using ContactMang.Business.DB; using ContactMang.Business.Unit; using DTO= ContactMangDTO; public interface IUserService     {         List<DTO.LoginUser> GetAllLoginUsers();         DTO.LoginUser GetLoginUser(string userName);         DTO.LoginUser GetLoginUser(long userId);         DTO.LoginUser RegisterLoginUser(DTO.LoginUser loginUser);     } ------------------------  public class UserService:IUserService     {         private MyUnitOfWork unitOfWork = new MyUnitOfWork();         public UserService()         { }         public List<DTO.LoginUser> GetAllLoginUsers()         {             List<DTO.LoginUser> usrList=new List<DTO.LoginUser>();     ...

#AT Repository and Unit of Work Pattern - 5

UnitOfWork Layer creation Add a folder in CMBusinessTyre project Named UnitOfWorkLayer add 2 Interface and 2 class files. IMyUnitOfWork IGenericRepository MyUnitOfWork GenericRepository public interface IMyUnitOfWork    {         int Commit();    } ------------------------------------------------- public interface IGenericRepository<T>     {         IEnumerable<T> GetData();         T GetByID(object id);          T Insert(T entity);         void Delete(object id);         void Update(T entityToUpdate);         IEnumerable<T> FindBy(Expression<Func<T, bool>> predicate);         } ------------------------------------------------- public class MyUnitOfWork : IMyUnitOfWork, IDisposable     {         private Gen...

#AT Repository and Unit of Work Pattern - 4

2. DataBaseLayer Creation select solution in solution explorer->right click ->add project->new->select class library->CMBusinessTyre. Right Click CMBusinessTyre->add folder->CMDatabaseLayer Right click CMDatabaseLayer -> add new item ADO.Net Entity data model file.<CMContext> as name. ADO.Net Entity data model Wizard Select EF Designer from Database Select New connection, fill                       1. Server name                       2. Logon credentials                       3. Select Database                       4. Test connection Select Yes. include info in connection string Give connection string as u required. Eg. ContactManagerContext. Select required objects (Table. SP, View) If required change model name(optional)...

#AT Repository and Unit of Work Pattern - 3

DTO service library creation Right click on solution and add new Service Library project. Add class file for models. Eg  public class LoginUser     {         public long Id { get; set; }         public string Name { get; set; }         public string Password { get; set; }         public string Status { get; set; }     } --------------------------------------------------- public class Address     {         public long id { get; set; }         public long? ContactId { get; set; }         public string Door { get; set; }         public string Street { get; set; }         public string Place { get; set; }         public string City { get; set; }         public string Taluk { get; set; }         p...

#AT Repository and Unit of Work Pattern - 2

Creating a sample application I am going to create to projects in a solution. BusinessTyre and WCF restful/web api   DTO (data transfer object) 1. BusinessTyre  is going to have below folders, DataBaseLayer for edmx UnitOfWork for unit of work and generic repository Service 2. WCF restful for proving the service to any presentation project. WCF restful project. 3. DTO will have the models that are user for data transfer.(not DB models. common to service and business project) let we start coding... create DB and tables CREATE TABLE [dbo].[LoginUser]( [Id] [bigint] IDENTITY(1,1) NOT NULL, [Name] [varchar](30) NULL, [Password] [varchar](30) NULL, [Status] [char](1) NULL DEFAULT ('A'), PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] ------------------------------ CREATE TABLE [dbo].[LogRegiste...

#AT Repository and Unit of Work Pattern - 1

Repository and Unit of Work Pattern Repository and Unit of work pattern provides a clean way to access data using ORMs, keep all the data access logic in one central location and at the same time maintain the test-ability of the application. Improve the code's maintainability and readability by separating business logic from data or service access logic. To maximize the amount of code that can be tested with automation and to isolate the data. What is the use of Unit of Work design pattern? Unit of Work design pattern does two important things: first it maintains in-memory updates and second it sends these in-memory updates as one transaction to the database. So to achieve the above goals it goes through two steps: It maintains lists of business objects in-memory which have been changed (inserted, updated, or deleted) during a transaction. Once the transaction is completed, all these updates are sent as one big unit of work to be persisted physically in a...

AngularJS - 02 (Intro Coding)

AngularJS is distributed as a JavaScript file,  and can be added to a web page with a script tag: < script   src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js" > < /script > < !DOCTYPE   html > < html > < script   src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js" > < /script > < body > < div   ng-app= "" >   < p > Name:  < input   type= "text"   ng-model= "name" > < /p >   < p   ng-bind= "name" > < /p > < /div > < /body > < /html > Example explained: AngularJS starts automatically when the web page has loaded. The ng-app directive tells AngularJS that the <div> element is the "owner" of an AngularJS application. The ng-model directive binds the value of the input field to the application variable name . The ng-bind directive binds the inn...

AngularJS - 01 (Intro)

AngularJS AngularJS is a very powerful JavaScript Framework. It is used in Single Page Application (SPA) projects. It extends HTML DOM with additional attributes and makes it more responsive to user actions. AngularJS is open source, completely free, and used by thousands of developers around the world. It is licensed under the Apache license version 2.0. AngularJS is created by Google, which is probably one of the bigger causes of its success. Prerequisites You should have a basic understanding of JavaScript and any text editor. As we are going to develop web-based applications using AngularJS, it will be good if you have an understanding of other web technologies such as HTML, CSS, AJAX, etc. What is AngularJS? AngularJS is an open source web application framework. It was originally developed in 2009 by Misko Hevery and Adam Abrons. It is now maintained by Google. Its latest version is 1.4.3. Definition of AngularJS as put by its official  documentation The Angula...