Gym Buddy – gym membership [615365]
1
Gym Buddy – gym membership
administration system
Lucrare de licență
Coordonator științific:
Lect. univ. dr. Nume Prenume Coordonator Principal
Absolvent: [anonimizat] ”OVIDIUS” din Constanța
Facultatea de Matematică și Informatică
Specializarea Computer Science
2
Content
1. Introduction ………………………….. ………………………….. ………………………….. …………. 3
1.1. Motivation ………………………….. ………………………….. ………………………….. …………. 3
1.2. Structure of the project ………………………….. ………………………….. ……………………. 4
1.3. Structure of the paper ………………………….. ………………………….. ………………………. 4
2. Technologies us ed………………………….. ………………………….. ………………………….. …. 5
2.1. Web application ………………………….. ………………………….. ………………………….. ….. 6
2.1.1. ASP .NET ………………………….. ………………………….. ………………………….. ……. 6
2.1.2. Model -View -Controller(MVC) ………………………….. ………………………….. …… 7
2.1.3. Microsoft SQL Server ………………………….. ………………………….. ……………….. 8
2.1.4. HTML, CSS, Javascript, jQuery ………………………….. ………………………….. …. 9
2.1.5. WCF Service ………………………….. ………………………….. ………………………….. 10
2.2. Mobile application ………………………….. ………………………….. …………………………. 11
2.2.1. Android ………………………….. ………………………….. ………………………….. ……… 11
2.2.2. Flutter ………………………….. ………………………….. ………………………….. ……….. 13
2.2.3. Firebase ………………………….. ………………………….. ………………………….. …….. 15
2.2.4. NFC(Near Field Communication) ………………………….. ………………………….. 17
3. Application presentation ………………………….. ………………………….. …………………. 18
3.1. Web application presentation ………………………….. ………………………….. ………….. 18
3.2. Mobile application presentation ………………………….. ………………………….. ………. 18
4. Design and implementation of the applications ………………………….. …………….. 18
4.1. Implementation of web application ………………………….. ………………………….. ….. 18
4.2. Implementation of Android application ………………………….. ………………………… 24
4.3. Implementation of WCF Service ………………………….. ………………………….. ……… 24
4.4. Database Impleme ntation ………………………….. ………………………….. ……………….. 26
4.5. The interaction between components ………………………….. ………………………….. .. 30
3
5. Conclusions ………………………….. ………………………….. ………………………….. ………… 31
5.1. Future improvements ………………………….. ………………………….. ……………………… 31
1. Introduction
1.1. Motivation
The main objective of the GymBuddy system is to improve the way a user s igns up for a gym
membership, checks in to the gym and stays in touch with the gym staff .
To achieve this, the android application let’s the user create an account and choose the type
of membership he want s to sign up for . When the user enters the gym he will go to the front
desk, select the membership he wants to use from the mobile application and touch the NFC tag
with the back of his phone. A popup will appear in the web application containing the
membership details an d statu s. The gym staff can then e asly identify the type of membership and
if the user can proceed with his workout or he has to renew his expired membership.
To keep in touch with it’s customers and keep them engaged, the staff can add, from the web
appli cation, artciles that can be read in the news section of the mobile application or alerts that
can notify the user of different gym related events. The communication is also facilitated by the
fact that both of these come joined with a push notification on the de vice.
Along with signing fo r the initial membership, the app lets the user add new ones at any time
as well as cancel any active ones. When adding a membership, the initial status will be
„Awaiting payment”, so the user will have to make the paymen t on hi s first checkin. To make
sure the membership is still active, the user can check the status, start date and end date for each
membership from the mobile app dashboard, along with statistics like the last checkin date, total
checkins and checkins thi s month
4
1.2. Structure of the project
GymBuddy is a two -part management system for gym memberships that will consist of an
Android application( GymBuddy App ) and a web application( GymBuddy Management ).
GymBuddy App
GymBuddy App is an Android application developed in Flutter and used as a compa nion and
gym card that contains 3 sections:
• Dashboard
• News
• Alerts
The main use of the application is to ease the access in the gym using NFC tags placed at the
entrance. When the phone touches the NFC tag, the application will se nd a push notification to
the GymBuddy Management web application, where the type and status of the notification will
be verified and displayed as a pop -up. The action on NFC trigger will happen only when the user
taps the checkin button to minimize power consumption.
GymBuddy Manag ement
GymBuddy Management is a web application developed in ASP .Net MVC used by the gym
staff in order to better manage memberships.
In the Membership Types and Memberships section s, employees can create, edit and delete
members hip types and change status for memberships created by the users in the app.
The news section is where the staff can stay in touch with the clients. They can select
between alerts (small i nformational messages) and articles(text with pictures) and on submi t,
users will receive a not ification that will open the News section of the mobile application.
Every time a user touches the access NFC tag, a colored pop -up(red for expired memberships
and green for valid ones) will appear in the web application with inf ormation about the user and
membership and from which you can change its status.
1.3. Structure of the paper
In this paper will be addressed all the theoretical notions necessary to meet the proposed
objective, that of building a system consisting of an mobil e application that will run on the
Android operating system and a web application connected via a WCF Service .
Thus, in the next chapter will be presented the technologies used in building the two
applications . Split in two parts, the first one presents th e technologies used for the web
5
application including ASP .NET MVC, SQL Server, HTML, CSS, Javasctipt, jQuery and WCF
Services while the second part presents t he technologies used for the mobile application like
Flutter, Dart, Firebase and also the structu re of the operating system presenting each level of it.
All these technologies will be addressed through the study of specialized literature and official
docum entation.
The third chapter showcases a presentation of each application and each of its features and
functionalities .
The forth chapter will present the structure of the application s, their development process and
how to implement the notions presented in the previous chapter s.
The last chapter of this paper presents possible further developments of this application as
well as the conclusions we reached after the development.
2. Technologies us ed
In the following will be detailed the technologi es used in the realization of the project.
The project was developed using open -source technologies and too ls, well documented,
widesp read and with communities of users and developers concerned with their efficient use and
continuous development.
This choice has the following advantages:
• Low cost for application development, no need to pay licensing fees for the technologies
used;
• There is support from communities that support these technologies such as tutorials,
discussion forums on various top ics (errors, good practices) and access to various
resources such as specialized bookstores.
Fig 2. 1 Used technologies ASP .NET
SQL
ServerHTML
CSSJavascript
WCF
ServiceFirebase
FCM
FlutterAndroid
6
Fig 2.1 represents a structure of the technologies I used in the implementation of the solution.
2.1. Web application
2.1.1. ASP .NET
ASP .NET is a technology developed by Microsoft th rough which highly complex web
applications and services can be build . This technology includes a series of benefits, among
which we mention: writing applications using the functions of languages and programming
environments developed, the existence of a familiarity with c ertain scripting techniques (PHP
and Javascript) a nd the possibility of designing web services.
Usually with this type of technologies , the controls are made manually, and the
programmer's task is to implement how to assert them according to the actions p erformed by the
user.
.NET is a framework that ac ts independently of the platform. It has the ability to
support a multitude of programming languages, such as C#, VB .NET and others. The most
important benefit of this framework is the ability to provide a common set of class libraries,
which can be acces sed regardless of the .NET programming language. What adds value is the
fact that there is no separability between class sets and libraries depending on the target
language.
Microsoft .NET is perceived as software that establishes the connection between
people, information, devices and systems. It includes clients, development tools and servers.
There are a lot of benefits to the .NET framework, with its ability to support more than
twenty distinct progra mming languages, the ability to manage much of the installations directly
involved in the software development process, and the ability to simplify the construction,
management and deployment of applications with a high level of security, resilience and a high
level of performance. The .NET framework incl udes a common language runtime and a unitary
set of class libraries.
Common Language Runtime (CLR)
CLR specializes in run -time services, such as language integration, increased security,
efficient memory usage, and thread handling.
Class library
The basic classes provide a uniform set of functionalities: input / output operations,
network communication mode and others. ADO .NET classes facilitates the possibility for
developers to inter act with data in XML format, which can be accessed through the OLE DB,
Oracle, SQL Server and ODBC interfaces.
7
XML classes make it easy to search, manipulate, and translate XML. ASP .NET classes
represent the necessary foundation for the development of We b applications, respectively Web
services. Windows Forms -based cla sses provide the support you need to develop complex
desktop applications.
2.1.2. Model -View -Controller(MVC)
Model -View -Controller has emerged as a solution to simplify the way users handle
data management and focuses on division of responsibilities. The name of the notion of MVC
provides a precise explanation of how it operates, so you can assign the keywords in its
composition with the following responsibilities:
• "model " – manages the state and logic of the application, ignoring the interaction between
the us er and the corresponding interface
• "view " – manages the creation of the user interface based on data and changes in the
states the model goes through. This part ignores the application logic as well as how to
retrieve the data and focuses only on the corre ctness of the state of the model at a given
time.
• "controller " – manages the translation of commands made by the user into a language
known to the compiler. This part ig nores the reason for translating user actions.
MVC comprises a variety of adva ntages, the most important being the transposition of
information (model) in different forms, the easy insertion, modification or deletion of user
interfaces simultaneou sly with the execution and / or compilation of the program and the
simultaneous updatin g of the interface, input data , or logic without affecting the other source
code.
Although the parts of a Model -View -Controller seem to be independent entities, they
communicate frequently, otherwise it is not possible to achieve the goal. Communi cation
between the three parties is ensured by the existence within each separable entity of a reference
to the object with which it interacts.
The controller analyzes the received signals and sends the commands to the model to
execute the requi red changes. The tasks of the model are to control one or more components of
the data source and to send a response consistent with the current state of the system, taki ng into
account the degree to which this state can be changed. The "view" part is a bri dge between the
user and the application.
8
Fig 2.2 Model -View -Controller operation model
Fig 2.2 highlights how the components of an MVC interact to achieve a common object.
2.1.3. Microsoft SQL Server
SQL is an advanced architecture through which relationa l databases can be created and
manipulated across a variety of platforms. The SQL language is referred to in various forms,
mentioning that all these have as a f undamental element the ANSI SQL standard . SQL is
associated by Microsoft SQL Server with the na me "Transact -SQL".
The S QL language is divided into two categories: data definition language (DDL) and
data manipulation language (DML). The operations allowed by the language for defining data
are the creation and deletion of databases, compared to the operations of adding, deleting,
modifying and querying made available within the language intended for data manipulation.
Microsoft SQL Server is used to streamline and simplify analysis and information
manipulation techniques. Its purpose is to facilita te the management of databases, ensuring a
high level of security. The advantages offered by SQL Server aim at security, rel iability,
scalability, performance, data sharing and maximizing the productivity of the applications
undertaken.
SQL Command Funct ionality
CREATE – creation of the database and subsequent compilation of data
tables
USE – pointing to the targeted database for immediate use
ALTER – altering the database structure
DROP – deleting the database
SELECT – selecting data from a specified table to be displayed
INSERT – inserting data in a specified table
UPDATE – edit the content of a specified record
DELETE – deleting a specified record
Table 2. 1 SQL main operations
SQL Server can be used from three different perspe ctives, depending on the user's need:
9
• Enterprise Data Management – used to design analytical and business applications. It is
identified by security and productivity given to applications.
• Business Intelligence – used when the application involves the use of a large volume of
data, the movement of inputs and the need to integrate with various products . It is
identified by the rapid rise in application quality.
• Stored procedures – associated with the term "constructor" in object -oriented
programming language s. It is identified by facilitating a simplified development process.
The mechanism by which the development process decreases in complexity is given by
the grouping of Transact -SQL commands, which can be parameterized later.
Microsoft SQL Server helps i ncrease performance, reduce costs, streamline source
code, and increase the security level of cop yright assignment.
2.1.4. HTML, CSS, Javascript, jQuery
HTML (Hypertext Markup Language) is one of the fundamental elements of the Wor ld
Wide Web and has the role of describing how documents are distributed and viewed on the Web.
An important advantage of this is the independence from the platform, to which can be added the
formatting format and hypertext links.
The browser does not display HTML bookmarks, instead it uses them to interpret the
content of a page. The indications provided by HT ML tags show a variation in terms of
simplicity.
Also, HTML tags have an important role because they allow the specification of
metadata that includes information about the d ocument or information about how to structure the
document. The links between do cuments are called hyperlinks.
CSS (Cascading Style Sheets) is a language for styling HTML tags and elements. How
styles are assigned to different HTML elements is done using external files or even inside the
document, using the keyword "style". Another way to use CSS is to format SVGL, XML and
XHTML elements.
CSS was born from the need to separate the content of the document written in HTML
from its stylization using colors , orientation and font. The need for this separation gives
flexibility and contr ol in terms of specification and modification of certain features in the
presentation. An important feature offered by this language is the elimination of redundancy
regarding the repeatability of specifying a style for multiple targeted elements. In addit ion, CSS
offers the possibility for the same page to benefit from different formats in terms of presentation
and depending on the method of playback.
The CSS syntax is catego rized into three levels:
10
• Level 1 includes the characteristics of the tags in an HTML document. In this case the
"style" attribute is used
• Level 2 contains the information located in the HEAD block. In this case the <style>
mark is used
• Level 3 contains com mands located on separate pages
Level one is the level with the highest priority, compared to level three, which contains
the minimum priority.
The application implemented in this paper uses CSS for a more attractive presentation
of the content and pag es of the implemented applicatio n.
JavaScript is an object -oriented programming language that relies on the concept of
prototypes and was designed by Communications Corporation and Brenden Eich. It is frequently
used especially for introducing certain fu nctionalities in web pages, the code of this language
being run by the browser. The syntax of this language is similar to that of the C language.
Being a scripting language, its role is to give interactivity to HTML pages. It has a
number of advantages through the programming tool tha t represents a support for HTML
designers, through the dynamic way of inserting a text in the composition of an HTML page, by
the way it reacts to events, by reading and writing HTML elements, by ratifying data , by the
way of creating cookies and by the w ay of detecting the browser of a certain user.
jQuery is a library designed to give simplicity to client -side scripts, specifically those
made with HTML components. This language offers multiple advantages by simplifying
navigation in a document, making animations, selecting elements in the DOM, developing A JAX
applications and event management.
Through this language, developers have the opportunity to design extensions that will
later be incorporated into Javascript libr aries. In this way, an abstraction of effects, animations,
respectively interactions is obtained.
2.1.5. WCF Service
Windows Communication Foundation (WCF) is an API within the .NET Framework
used to build connected services (SOA) based applications.
WCF was designed in accordance with SOA principles for the implementation of
distributed programming, where services are consumed by consumers. Customers can consume
more services, and services can, in turn, be consumed by more customers. Services are poorly
conn ected. Usually, the services offer a WSDL interface, which any WCF cli ent can use to
consume the service, regardless of the platform on which the serial is hosted. WCF implements
several advanced standards for web services, such as WS -Addressing, WS -Reliab leMessaging,
11
and WS -Security. With the release of the .NET Framework v ersion 4.0, WCF also offers services
for using the Really Simple Syndication (RSS) family of formats.
A WCF service consists of 3 parts – a Service class that implements the service to be
provided, a host environment to host the service, and one or more endpoints to which customers
will connect. All communication with the WCF service takes place via endpoints. Endpoints
specify a Contract that defines which methods in the Service class will be accessible through the
endpoint; each endpoint can expose a di fferent set of methods. In conclusion, endpoints define a
link that specifies how a customer will communicate with the service and the address where the
endpoint is hosted.
A WCF clien t connects to a WCF service using an endpoint . Each service exposes it s
contracts through one or more endpoints. An endpoint has an address, which is a URL specifying
where the endpoint can be accessed, and connection parameters, which specify the data tra nsfer.
When a customer wants to access the service through an endpoi nt, it is not enough just
to know the contract, but also to accept the type of connection specified by the endpoint. So both
the client and the server must have compatible endpoints.
With the release of the .NET Framework version 3.5 in November 2007, Mi crosoft
released an encoder, which provides the WCF platform with the necessary support for the JSON
serialization format. This allows services developed using WCF to respond to requests sent by
web pages via AJAX methods.
2.2. Mobile application
2.2.1. Android
Android is an open source product created by Google and its development continues
with the Open Handset Alliance and consists of a collection of software components that
includes an operatin g system, middleware and key applications for mobile devi ces, including
smartphones. in order to be able to use their resources efficiently in offering various
functionalities to users
Android features
Among the characteristic elements of the Android sys tem are the following:
• Open -source platform. Android is an open source product, distributed under the Apache
License version 2 (except for the Linux kernel which is licensed under the GPL version
2), a fairly permissive license that offers the freedom to c opy, distribute and mod ify the
continuity freely without no licensing costs, leaving it to the choice of developers
whether to distribute the modified sources under the same license or not. The only
Android element that is an exception to this rule is the Linux kernel which is l icensed
12
under the GPL version 2 which means that any change of sources must be made public
and further distributed free of charge under the GPL license version 2.
• Portability to run on a wide range of current and future hardware. Al l programs are
written in Java and run on the Dalvik virtual machine, with the possibility of porting code
on ARM, x86 and other architectures. User interfaces can be adapted to any resolution
that devices may have.
• Architecture based on components that al lows the reuse of compo nents in various
applications as well as their replacement.
• Provides support for 2D and 3D graphics using OpenGL ES 1.0
• Ability to store data in the form of SQLite databases.
• Support for common audio, video, and image media format s (MPEG4, H.264, MP3,
AAC, AMR, JPG, PNG, GIF)
Android also provides developers with a number of useful tools for developing
applications such as emulator, debugging tools, for measuring application performance, and the
possibility of integration with E clipse IDE .
Android is continuously under development . Each released version brings
improvements to various existing components as well as new elements and features to make
better use of physical resources of devices.
Versions
Each version of Android released repr esents an API level (API level) and is an
important criterion that must be taken into account in the process of designing applications for
this platform. Thus, if an application is designed for a high API level corresponding to a recent
versio n of Android then it will not be able to work on devices running earlier versions and if an
application is designed for a low API level, it will be able to run on multiple devices who have
higher versions of Android installed but will not benefit from all the features offered by higher
versions.
Android 9 brings a host of new features, like stronger protections for user privacy, new
ways to engage users, Vulkan extensions, and more . Based on this criterion, Android 9 – Pie was
chosen corresponding to API l evel 28 as the target platform.
13
Fig 2.3 Distribution graphic off Android versions
At the core of the Android architecture is a Linux 2.6 kernel that provides basic system
functionality such as file system management, process management, memory, netwo rking
elements, and drivers.
Libraries
The second level of architecture consists of a set of C / C ++ libraries that underlie the
operation of various components of the Android system.
These libraries include:
• A subset of the standard C (libc ) librar y specifically adapted for mobile devices running
Linux.
• A series of media libraries that support common audio and video formats such as
MPEG4, H.264, MP3, AAC, AMR, JPG and PNG
• Support for 2D graphics (features provided by the SGL graphics engin e) and 3 D (features
provided by the OpenGL ES library 1.0)
• FreeType – a library that provides playback of vector or bitmap fonts
• SQLite – Database with which persistent data can be stored.
2.2.2. Flutter
Flutter is an innovative, open -source UI software develo pment ki t created by Google and
released in May 2017 that allows you to create native -looking Android and iOS applications with 0.21.7 4
9.2
11.2
12.9
21.331.38.2Android versions
ICS Jelly Bean KitKat Lollipop Marshmellow Nougat Oreo Pie Android 10
14
only one codebase. This means that you can write your code once and it will run on both iOS and
Android .
Benefits of Flutter include:
• Great performance : Flutter compiles the code directly to native code. This ensures fast app
startup and better performance overall.
• Quick development : Flutter uses hot reload, a function that allows you to view the changes
applied to the c ode on the device i nstantly.
• Compatibility : Flutter comes with its own widgets which results in fewer compatibility
problems.
• Open -source: Both Dart and Flutter are free to use and surrounded by active community of
developers that contribute to the tool’s extensive documenta tion
Flutter consists of two important parts:
• An SDK (Software Development Kit): A collection of tools which will help you develop
your applications. This includes tools to compile your code into native machine code
(code for Android and iOS).
• A Framework (UI Library based on widgets): A selection of reusable UI elements ( text
inputs, buttons, sliders, and so on) that can be personalized for your own needs.
Flutter Widgets
Flutter widgets are built as a way to declare and construct UI. Widgets describe what their
view should look like given their current state and configuration . When something happens in
the application, the state of the widget changes , the widget rebuilds i ts description, which the
flutter framework compares against the previous description in order to determine a set of
minimal changes needed in the render tree to transition from one state to the other .
Types of widgets
Flutter has a long list of in -built widgets for animations, texts, buttons, sliders, navigations,
lists, gesture detector, etc. Flutter team works really hard make sure there is a set of widgets that
can help you in almost any situation , and they are conti nuously adding more widgets to meet
developers needs . But apart from built -in widgets, you can create your own widgets acc ording to
your specifications .
Flutter divides widgets into two main categories:
• Stateless Widgets
If a widget doesn’t do anything its Stateless Widget. They are static in nature.
Stateless widgets don’t store any state which means they cannot change.
15
For example, if you just display a simple Text widget on the screen, but it doesn’t change
in any way, then its Stateless Widget.
Texts and icons are examples of stateless widgets.
• Stateful Widgets
If a widget does anything then its Stateful Widget.
A Stateful widget is dynamic in nature. That means it can keep track of changes and
update the UI based on t hose changes.
Stateful widgets can be interacted with. For example, If you swipe item from a list and
item gets deleted then that list is a Stateful Widget.
Sliders and TextFields are examples of stateful widgets.
Dart
The main programming language used while developing with Flutter is called Dart. Dart is
an object -oriented language with a syntax similar with C that focuses on front -end development .
It can be compiled to either JavaScript or native code.
2.2.3. Firebase
Firebase is a Backend -as-a-Service(Baas) build on Google’s infrastructure that provides a
variety of tools and services to help developers make high -quality apps and grow their user base.
It is a full y managed platform for building oOs, Android and web apps that p rovides
automatic data syncronization, authentication services, messaging, file storage, analytics and
more, making it one of the most efficient ways of building or prototyping mobile backend
services.
Some of the tools Firebase offers are:
• Analytics
o Unlim ited reporting of 500 event types, each with up to 25 attributes
o One dashboard to view user behavior and cross -network campaign performance
o Demographic segmentation, including age, gender, a nd location, available out -of-
the-box
• Cloud messaging
o Send unli mited upstream/downstream messages.
o Send messages to individual devices or a user segment
o Handle all aspects of queuing and delivery
o It can send billions of messages with 95% of messages se nt in 250ms.
16
• Authentication
o Support multiple social accounts.
o Optional, out -of-the-box authentication UI optimized to give your users the best
experience
o It can also integrate to your existing accounts.
o Advanced functionality like email verification, an onymous accounts, and accoun t
linking
o Firebase will also manage user session
• Real time database
o A cloud -hosted NoSQL database.
o Intuitive and easy -to-use API
o Remains responsive regardless of network latency or Internet connectivity
o Handles the complexit y of real time synchronization and provides flexible conflict
resolution
o Accessible directly from client SDKs, or from your server with the REST API
• Storage
o Robust uploads and downloads in the background, regardless of network quality
o Secure client -side authorization, integrated with Authentication
o Petabyte scale data storage backed by Google Cloud Storage
o API access throughout Firebase or Google Cloud Storag e APIs
• Crash reporting
o Prioritize crashes by frequency and impact.
o Comprehensive data surroundi ng each crash, including device characteristics,
device circumstances, a stack trace, and more
o Reliably collect crashes that occur while the device is online o r offline
• Notification
o Send free and unlimited notifications across Android, and iOS.
o Send mess ages and analyze effectiveness in one dashboard without writing any
code
o Integrate with Firebase Analytics to deliver messages to a user segment
• Dynamic links
o Improve acquisition and engagement by bringing users directly to content that they
were original ly searching for, whether they have your app installed or not.
o Delight new users with personalized promotions and messages after install.
17
2.2.4. NFC(N ear Field Commun ication )
NFC is a wireless data transfer method that detects and then enables technology in clos e
proximity to communicate to each other without the need for an internet connection.
NFC devices can also act either as electronic identity documents or keycards . They are used
in contactless payment systems and allow mobile payment replacing or supplementing systems
such as credit cards and electronic ticket smart cards. This is known as NFC /CTLS or CTLS
NFC , with contactless abbreviated CTLS . NFC can be used for bootstrapping fast connections to
share larger media such as photos, videos, and other files or for sharing small files such as
contacts.
NFC -enabled portable devices can be provided with dedicated software , for example, to read
electronic tags or open doors when connected to an NFC -compliant apparatus.
Every active NFC device can work in one or more of three modes:
1. NFC card emulation
• Enables NFC -enabled devices such as smartphones to act like smart cards, allowing users
to perform transactions such as payment or ticketing.
2. NFC reader/writer
• Enables NFC -enabled devices to read information stor ed on inexpensive NFC tags
embedded in labels or smart posters.
3. NFC peer -to-peer
• Enables two NFC -enabled devices to communicate with each other and exchange
informatio n.
NFC tags are passive data stores w hich can be read, and under some circumstances writt en
to, by an NFC device. They typically contain data (as of 2015 between 96 and 8,192 bytes) and
are read -only in normal use, but may be rewritable. Applications include secure personal data
storage (e.g. debit or credit card information, loyalty program data, personal identification
numbers (PINs), contacts). NFC tags can be custom -encoded by their manufacturers or use the
industry specifications.
18
3. Application presentati on
3.1. Web application presentation
3.2. Mobile application presentation
4. Design and implementation of the application s
In this chapter, specific parts of the app lications implementation will be shown and
discussed.
4.1. Implementation of web application
As mentioned in the previous chapter s, the main technology used while implementing the
web application was ASP .NET MVC. This, combined with the abovementioned technologies
like jQuery, JavaScript , CSS and HTML helped creating the CRUD ( Create, Read, Update, and
Delet e) functionalities of the app.
To observe the implementation of these functionalities in the app, we will study the
“Membership Types” section of the app. Also, because it follows the MVC standard, the
application is divided into 3 main components – Model , View , and Controller .
Represen ting the shape of the data , the Model is a class which is used to store the data
retrieved from the database. As it can be observed in fig 4.1, for the MembershipTypeModel, the
class contains the attributes MembershipTypeId, Price, Type, Period, which correspond to the
fields in the Database and which have the Form validations, as well as Index, an attribute used to
number the entries for each table.
19
public class MembershipTypeModel
{
public int Index { get; set; }
public int MembershipTypeId { get; set; }
[Display(Name = "Price")]
[Required]
public double Price { get; set; }
[Display(Name = "Type")]
[Required]
public string Type { get; set; }
[Display(Name = "Period" )]
[Required]
public int Period { get; set; }
}
Fig 4.1 MembershipTypeModel class
In order to display model data to the user and also enable them to modify said data, we use
the View component of the system which rep resents the user interface . This was developed using
HTML, CSS, JavaScript and some special synt ax (Razor syntax) that makes it easy to
communicate with the model and the controller . For the “Mem bership Types ” section, the main
listing page consists in a sim ple table while d e pages for adding and editing the membership
types consists of html forms wi th its specific input elements.
To better facilitate the communication between the view and the cont roller , we used Razor
markups while build ing the forms as it can be observed in Fig. 4.2 . Html.BeginForm method
accepts arguments like “EditMembershipType ”, “Membe rshipType ” and FormMethod.Post
which represent the action , controller and request type that will be triggered a t form submit.
20
using (Html.BeginForm( "EditMembershipType" , "MembershipType" , new { ReturnUrl =
ViewBag.ReturnUrl }, FormMethod.Post, new { role = "form", @class = "form-horizontal p -t-
20" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary( true, "", new { @class = "text-danger", @role = "alert" })
@Html.HiddenFor(m => m.MembershipTypeId)
<div class="form-group row">
@Html.LabelFor(m => m.Type, new { @class = "col-sm-3 control -label" })
<div class="col-sm-9">
@Html.TextBoxFor(m => m.Type, new { @class = "form-control col -sm-8",
@type = "text", @required = "" })
<div class="form-control-feedback">
<small><code>@Html.ValidationMessageFor(m => m.Type, "")</code></small>
</div>
</div>
</div>
…
Fig 4.2 Razor synta x for a form and its elements
All the HTTP requests r aised by t he user in the view are handled by the Controller which
processes it and returns the appropiate response.
Controller Code
public class MembershipTypeController :Controller
{
private IDatabaseService _dbService;
public MembershipTypeCon troller(IDatabaseService dbService)
{
_dbService = dbService;
}
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult LoadMembershipTypes()
{
var draw = Request.Form.GetValues( "draw").FirstOrDefault();
var start = Request.Form.GetValues( "start").FirstOrDefault();
var length = Request.Form.GetValues( "length" ).FirstOrDefault();
var sortColumn = Request .Form.GetValues( "columns[" +
Request.Form.GetValues( "order[0][column]" ).FirstOrDefault() +
"][name]" ).FirstOrDefault();
var sortColumnDir = Request.Form.GetValues( "order[0][dir]" ).FirstOrDefault();
var searchValue = Request.Form.Get Values("search[value]" ).FirstOrDefault();
21
//Paging Size ( 10,20,50,100)
int pageSize = length != null ? Convert.ToInt32(length) : 0;
int skip = start != null ? Convert.ToInt32(start) : 0;
int recordsTotal = 0;
// Getting all data
var data = _dbS ervice.GetAllMembershipTypes().Select((i, index) => new
MembershipTypeModel()
{
Index = index + 1,
MembershipTypeId = i.MembershipTypeId,
Type = i.Type,
Period = i.Period.Value,
Price = i.Price
});
// Sorting
if (!(string.IsNullOrEmpty(sortColumn) &&
string.IsNullOrEmpty(sortColumnDir)))
{
if (sortColumnDir == "asc")
{
data = data.OrderBy(sortColumn + " ascending" ).AsQueryable();
}
else
{
data = data.OrderBy(sortColumn + " descending ");
}
}
//Search
if (!string.IsNullOrEmpty(searchValue))
{
searchValue = searchValue.ToLower();
data = data.Where(m => m.Type.ToLower().Contains(searchValu e) ||
m.Price.ToString().Contains(searchValue) || m.Period.ToString().Contains(searchValue));
}
//total number of rows count
recordsTotal = data.Count();
//Paging
var paging = data.Skip (skip).Take(pageSize).ToList();
//Returning Json Data
return Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal =
recordsTotal, data = paging });
}
[HttpGet]
public ActionResult AddMemb ershipType()
{
return View();
}
[HttpPost]
public ActionResult AddMembershipType(MembershipTypeModel model)
{
22
if (!ModelState.IsValid)
{
return View(model);
}
var membershipType = _dbService.GetAllMembershipTypes().FirstOrDefault(i =>
i.Type == model.Type);
if (membershipType != null)
{
ModelState.AddModelError( "", "There is already a membership type with
this name." );
return View(model);
}
var dbModel = new MembershipType()
{
Type = model.T ype,
Price = model.Price,
Period = model.Period,
};
var result = _dbService.AddMembershipType(dbModel);
if (result != null)
{
return RedirectToAction( "EditMembe rshipType" , new { membershipTypeId =
result.MembershipTypeId, actionId = ActionMessage.CreateSu ccess });
}
else
{
ModelState.AddModelError( "", "An error occured while performing this
action." );
return View(model);
}
}
[HttpGet]
public ActionResul t EditMembershipType( int membershipTypeId, ActionMessage?
actionId)
{
var membershipType = _dbService.GetMembershipType(membership TypeId);
if (membershipType == null)
{
ViewBag.NullMembershipType = true;
return View();
}
else
{
if (actionId.HasValue)
{
ViewBag.ActionId = actionId.ToString();
}
var model = new MembershipTypeModel()
{
MembershipTypeId = membershipType.MembershipTypeId,
23
Period = membershipType.Period.Value,
Price = membershipType.Price,
Type = membershipTy pe.Type
};
return View(model);
}
}
[HttpPost]
public ActionResult Ed itMembershipType(MembershipTypeModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var membershipType = _dbService.GetAllMembershipTypes().FirstOrDefault(i =>
i.Type == m odel.Type);
if (membershipType != null && membershipType.MembershipTypeId !=
model.MembershipTypeId)
{
ModelState.AddModelError( "", "There is already a membership type with
this name." );
return View(model);
}
var dbModel = new MembershipType()
{
MembershipTypeId = model.MembershipTypeId,
Type = model.Type,
Period = model.Period,
Price = model.Price
};
var result = _dbService.EditMembershipType(dbModel);
if (result)
{
return RedirectToAction( "EditMembershipType" , new { membershipTypeId =
model.MembershipTypeId, actionId = Ac tionMessage.UpdateSuccess });
}
else
{
ModelState.AddModelError( "", "An error occu red while performing this
action." );
return View(model);
}
}
[HttpPost]
public JsonResult DeleteMembershipType( int membershipTypeId)
{
var result = new Result()
{
24
Success = true
};
var membershipType = _dbService.GetMembershipType(membershipTypeId);
if (membershipType != null)
{
var dbModel = new MembershipType()
{
MembershipTypeId = membershipTypeId,
};
var dbResult = _dbService.DeleteMembershipType(dbModel);
if (!dbResult)
{
result.Success = false;
result.Message = "An error occured while performing the action.
Please try later." ;
}
}
return Json(result);
}
}
4.2. Implementation of Android a pplication
4.3. Implementation of WCF Service
In this ch apter, we introd uce our WCF Service and some of its endpoints . WCF has been
designed in accordance with SOA principles for the implementation of distributed programming,
where services a re consumed by consumers. Customers can consume more services, and services
can, in tu rn, be consumed by more customers. Services are poorly connected. Typically, services
provide a WSDL interface, which any WCF client can use to consume the service, regar dless of
the platform on which the service is hosted.
A WCF service is made up of 3 pa rts — a service class that implements the service that will
be provided, a host environment to host the service, and one or more endpoints to which
customers will connec t. All communication with the WCF service takes place via endpoints.
Endpoints specify a Contract that defines which methods in the Service class will be accessible
through the endpoint; each endpoint can expose a different set of methods. In conclusion,
endpoints define a specific connection that a customer will communicate with the service and
where the endpoint is hosted.
Our WC F-service should be able to handle authentication in the app , create users and
memberships, provide user and membership details, provid e the news and the articles and handle
the check -in functionality . To help us ac hieve this we have 10 endpoints ha ndling both P OST
and GET requests and which are listed in Fig 4.3 .
25
[OperationContract]
[WebGet(UriTemplate = "/getnews?categoryid={categoryId}" , ResponseFormat =
WebMessageFormat.Json)]
NewsModel GetN ews(int categoryId);
[OperationContract]
[WebGet(UriTemplate = "/getuserinfo?userId={userId}" , ResponseFormat =
WebMessageFormat.Json)]
UserInfoModel GetUserInfo( int userId);
[OperationContract]
[WebGet(UriTemplate = "/getmembershiptypes" , ResponseFormat =
WebMessageFormat.Json)]
MembershipTypesListModel GetMembershipTypes();
[OperationContract]
[WebGet(UriTemplate = "/getarticle?articleid={articleId}" , ResponseFor mat =
WebMessageFormat.Json)]
ArticleModel GetArticle( int articleId);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate =
"/signup" , ResponseFormat = WebMessageFormat.Json)]
UserModel SignUp(UserModel model);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate =
"/addmembership" , ResponseFormat = WebMessageFormat.Json)]
UserModel AddMembership(UserModel mo del);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate =
"/login" , ResponseFormat = WebMessageFormat.Json)]
UserModel Login(UserModel model);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate =
"/checkin" , ResponseFormat = WebMessageFormat.Json)]
Result Checkin(UserModel model);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, UriTemplate =
"/checkuniqueemail" , ResponseFormat = WebMessageFormat.Json)]
Result CheckUniqueEmail(UserModel model);
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessa geFormat.Json, UriTemplate =
"/cancelmembership" , ResponseFormat = WebMessageFormat.Json)]
Result CancelMembership(UserModel model);
Fig 4.3 List of Operation Contracts present in the Service Interface
26
4.4. Database Implementation
The .NET Framework provides ADO .NET Entity Data Model (EDM) – an easy way to
create edmx files that describe the database schema and define the mappings between the EDM
and the d atabase. EDM is the foundation for the Entity Framework. It is an XML file, and
articles described by EDM are called entities.
There are 3 approaches to using Entity Framework:
• model first – allows you to create a new model using Entity Framework Designer , then
generate a database using the
• database first model – create the model using an existing database
• code first – create the first time classes, and then the database from those classes is
generated; Entity Designer is not used
For our application we used database fi rst model , meaning that the database wa s created in
Microsoft SQL Server and then imported in the application . All queries are stored in a diffe rent
service which is called every time it is needed v ia an interface. In the following code snippet can
be observed the four basic CRUD functions applied for the membership types.
27
public MembershipType AddMembershipType(MembershipType membershipType)
{
var obj = dbContext.MembershipTypes.Add(membershipType);
dbContext.SaveChanges();
return obj;
}
public MembershipType GetMembershipType( int membershipTypeId)
{
var issueValidations = dbContext.MembershipTypes.FirstOrDefault(i =>
i.MembershipTypeId == membershipTypeId);
return issueValidations;
}
public bool EditMembershipType(MembershipType membershipType)
{
var result = 0;
var dbModel = dbContext.MembershipTypes.FirstOrDefault(i =>
i.MembershipTypeId == membershipType.MembershipTypeId);
if (dbModel != null)
{
try
{
dbModel.Period = membershipType.Period;
dbModel.Price = membershipType.Price;
dbModel.Type = membershipType.Type;
dbContext.Entry(dbModel).State = EntityState.Modified;
result = dbContext.SaveChanges();
}
catch (Exception ex)
{
}
}
return result > 0 ? true : false;
}
public bool DeleteMembershipType(MembershipType membership Type)
{
var result = 0;
var dbModel = dbContext.MembershipTypes.FirstOrDefault(i => i.MembershipTypeId
== membershipType.MembershipTypeId);
try
{
dbContext.MembershipTypes.Remove(dbModel);
result = dbContext.SaveChanges();
}
catch (Exception ex)
{
}
return result > 0 ? true : false;
}
28
Fig 4.4 Implementation of CRUD functions using Entity Framework
Database structure
Fig 4.5 Tables Memberships, Users , MembershipTypes, MembershipStatuses and
Logs
Memberships table contains all registered membershi ps and their details :
• Membership Id – Primary key
• StartDate – Membership start date
• EndDate – Membership end dat e
• IsActive – Active status
• MemebershipTypeId – Foreign key for membership type
• StatusId – Foreign key for membership status
• UserId – Foreign key for the user
Users table contains all users that registered in the app :
• UserId – Primary key
29
• FirstName – User first name
• LastName – User last name
• PhoneToken – User phone token, used to send targeted notifications
• Password – Encrypted password
• Email – User email address
• PhoneNumber – User phone number
Logs table contains check -in logs from each user :
• LogId – Primary key
• UserId – Foreign key for user
• Timestamp – Date and time a user checked -in
Membership Types table contains every type of membership the gym can offer :
• Membership Type Id – Primary key
• Type – Type of membership
• Price – Price of membershup
• Period – How long will the mebership last
• Code – A code to help identi fy the t ype in the app
Membership Statuses table contains the statuses a membership can have :
• StatusId – Primary key
• StatusName – Name of the status
• StatusCode – A code to help identi fy the status in the app
30
Fig 4.6 Tables Articles and Art icleCategories
Articles table contains every article added in the application :
• ArticleId – Primary key
• Title – Membership start date
• Text – Membership end dat e
• TimeStamp – Active status
• CategoryId – Foreign key for membership type
• Image – Foreign key for membership status
ArticleCategories table contains all categories that can be applied to an article :
• CategoryId – Primary key
• Name – Category name
4.5. The interaction be tween components
31
5. Conclusions
The objective of this thesis was an implemen tation of a system which consists of a web
application and a mobile application designed to facilitate the interaction between gym staff and
users . The whole process of the application creation was described – starting from the
motivation, showing the reason it was dec ided to implement this application, con tinuing with the
structure of the paper and of the project . Following the structure , the next chapter is focuse d on
the design of the application, briefly going through technologies which were used and briefly
describing web and mobile application architectures. This serves as basis to next chapter,
implementation , which describes certain parts of im plementation pro cess in detail, which
includes descrip tion of WCF implementation , mobile app implementation and explaining the
database design . To conclude, the application was su ccessfully analyzed , designed, implemented
and tested and every part of the process was described in the thesis.
5.1. Future improvements
A first step in furthe r developing this system would be to expand its functionality. Good
examples of new features would be the addition of a coaching section. Like the check -in, the user
will be able to touch the NFC tag on various apparatus available in the gym and instru ctions for
use will be displayed on the phone. If the user still has questions , a button can be implemented to
ask for help. The employees of the gym would receive a notification similar to the check -in ones
with the location of the apparatus and the user's nam e.
Another place where you can use the application is in the locker rooms. When the user
checks in, he is assigned a locker number that can be opened using the phone.
Another feature that can be implemented is the use of a CRON that can send notif ications
automatically when a membership is about to expire or when a user has not checked in for some
time, motivating him to come to the gym. Lastly, to complete the companion function, the app
can monitor calories burned during training or heart rate.
On the administration side you can add statistics to have an overview of the used
memberships, active users or pre ferred membership types .
Copyright Notice
© Licențiada.org respectă drepturile de proprietate intelectuală și așteaptă ca toți utilizatorii să facă același lucru. Dacă consideri că un conținut de pe site încalcă drepturile tale de autor, te rugăm să trimiți o notificare DMCA.
Acest articol: Gym Buddy – gym membership [615365] (ID: 615365)
Dacă considerați că acest conținut vă încalcă drepturile de autor, vă rugăm să depuneți o cerere pe pagina noastră Copyright Takedown.
