Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Practico1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
G10TSI1
Practico1
Commits
a6f3c700
There was a problem fetching the pipeline summary.
Commit
a6f3c700
authored
Apr 3, 2016
by
Sebastian Barbosa
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into servicelayer
parents
2c371063
ec9a302e
Branches
servicelayer
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
DataAccessLayer/DALEmployeesEF.cs
+1
-3
1 addition, 3 deletions
DataAccessLayer/DALEmployeesEF.cs
DataAccessLayer/DALEmployeesMongo.cs
+29
-20
29 additions, 20 deletions
DataAccessLayer/DALEmployeesMongo.cs
with
30 additions
and
23 deletions
DataAccessLayer/DALEmployeesEF.cs
+
1
−
3
View file @
a6f3c700
...
@@ -51,9 +51,7 @@ namespace DataAccessLayer
...
@@ -51,9 +51,7 @@ namespace DataAccessLayer
}
}
}
}
//throw new NotImplementedException();
}
}
public
void
UpdateEmployee
(
Employee
emp
)
public
void
UpdateEmployee
(
Employee
emp
)
...
...
This diff is collapsed.
Click to expand it.
DataAccessLayer/DALEmployeesMongo.cs
+
29
−
20
View file @
a6f3c700
...
@@ -6,38 +6,50 @@ using MongoDB.Bson;
...
@@ -6,38 +6,50 @@ using MongoDB.Bson;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Shared
;
namespace
DataAccessLayer
namespace
DataAccessLayer
{
{
public
class
DALEmployeesMongo
:
IDALEmployees
public
class
DALEmployeesMongo
:
IDALEmployees
{
{
// Documentacion sobre MongoDB y C#
// https://docs.mongodb.org/getting-started/csharp/update/
private
IMongoClient
_client
;
private
IMongoDatabase
_database
;
//TODO: Ver si esta bien tener el cliente y la base estatica en la tabla, me imagino que abre una sesion y no expira pero anda a saber
public
DALEmployeesMongo
()
// No veo nada de pool y de keep alive, no debe de ser muy prolijo tenerlo aca
protected
static
IMongoClient
_client
;
protected
static
IMongoDatabase
_database
;
static
DALEmployeesMongo
()
{
{
_client
=
new
MongoClient
();
_client
=
new
MongoClient
();
_database
=
_client
.
GetDatabase
(
"tsi_pr1"
);
_database
=
_client
.
GetDatabase
(
"tsi_pr1"
);
}
}
public
void
AddEmployee
(
Employee
emp
)
public
void
AddEmployee
(
Employee
emp
)
{
{
throw
new
NotImplementedException
();
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
"EmployeesTPH"
);
BsonDocument
result
=
collection
.
Find
(
new
BsonDocument
()).
Sort
(
new
BsonDocument
(
"ID"
,
-
1
)).
FirstOrDefault
();
var
document
=
new
BsonDocument
{
{
"ID"
,
result
==
null
?
1
:
result
[
"ID"
].
ToInt32
()
+
1
},
{
"NAME"
,
emp
.
Name
},
{
"TYPE_EMP"
,
emp
is
FullTimeEmployee
?
1
:
0
},
{
emp
is
FullTimeEmployee
?
"SALARY"
:
"RATE"
,
emp
is
FullTimeEmployee
?
((
FullTimeEmployee
)
emp
).
Salary
:
((
PartTimeEmployee
)
emp
).
HourlyRate
},
{
"START_DATE"
,
emp
.
StartDate
}
};
collection
.
InsertOne
(
document
);
}
}
public
void
DeleteEmployee
(
int
id
)
public
void
DeleteEmployee
(
int
id
)
{
{
throw
new
NotImplementedException
();
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
"EmployeesTPH"
);
var
filter
=
Builders
<
BsonDocument
>.
Filter
.
Eq
(
"ID"
,
id
);
collection
.
DeleteOne
(
filter
);
}
}
//Bruno
public
void
UpdateEmployee
(
Employee
emp
)
public
void
UpdateEmployee
(
Employee
emp
)
{
{
// https://docs.mongodb.org/getting-started/csharp/update/
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
"EmployeesTPH"
);
var
collection
=
_database
.
GetCollection
<
BsonDocument
>(
"EmployeesTPH"
);
var
filter
=
Builders
<
BsonDocument
>.
Filter
.
Eq
(
"ID"
,
emp
.
Id
);
var
filter
=
Builders
<
BsonDocument
>.
Filter
.
Eq
(
"ID"
,
emp
.
Id
);
var
update
=
Builders
<
BsonDocument
>.
Update
var
update
=
Builders
<
BsonDocument
>.
Update
...
@@ -96,23 +108,20 @@ namespace DataAccessLayer
...
@@ -96,23 +108,20 @@ namespace DataAccessLayer
return
employee
;
return
employee
;
}
}
private
Employee
fromDocument
(
BsonDocument
document
)
private
Shared
.
Entities
.
Employee
fromDocument
(
BsonDocument
document
)
{
{
Employee
result
=
null
;
Employee
result
=
null
;
if
(
document
!=
null
)
if
(
document
!=
null
)
{
{
if
(
document
[
"TYPE_EMP"
].
ToInt32
()
==
1
)
if
(
document
[
"TYPE_EMP"
].
ToInt32
()
==
1
)
{
{
Shared
.
Entities
.
FullTimeEmployee
tmp
=
new
FullTimeEmployee
();
FullTimeEmployee
tmp
=
new
FullTimeEmployee
();
tmp
.
Salary
=
document
[
"SALARY"
].
ToInt32
();
tmp
.
Salary
=
document
[
"SALARY"
].
ToInt32
();
result
=
tmp
;
result
=
tmp
;
}
}
else
else
{
{
Shared
.
Entities
.
PartTimeEmployee
tmp
=
new
PartTimeEmployee
();
PartTimeEmployee
tmp
=
new
PartTimeEmployee
();
tmp
.
HourlyRate
=
document
[
"RATE"
].
ToDouble
();
tmp
.
HourlyRate
=
document
[
"RATE"
].
ToDouble
();
result
=
tmp
;
result
=
tmp
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment