Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsi1-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rodrigo Sastre Marotta
tsi1-backend
Commits
0b1cbe51
Commit
0b1cbe51
authored
4 years ago
by
esantangelo
Browse files
Options
Downloads
Patches
Plain Diff
add ErrorMessages
parent
4488aabf
No related branches found
Branches containing commit
No related tags found
1 merge request
!5
Multi tenancy
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tsi1.Api/Tsi1.BusinessLayer/Helpers/ErrorMessages.cs
+11
-0
11 additions, 0 deletions
Tsi1.Api/Tsi1.BusinessLayer/Helpers/ErrorMessages.cs
Tsi1.Api/Tsi1.BusinessLayer/Services/ForumService.cs
+30
-2
30 additions, 2 deletions
Tsi1.Api/Tsi1.BusinessLayer/Services/ForumService.cs
with
41 additions
and
2 deletions
Tsi1.Api/Tsi1.BusinessLayer/Helpers/ErrorMessages.cs
+
11
−
0
View file @
0b1cbe51
...
...
@@ -9,13 +9,24 @@ namespace Tsi1.BusinessLayer.Helpers
public
const
string
UserDoesNotExist
=
"El usuario '{0}' no existe"
;
public
const
string
IncorrectPassword
=
"Contraseña incorrecta"
;
public
const
string
UserTypeDoesNotExist
=
"El tipo de usuario con id '{0}' no existe"
;
public
const
string
StudentDoesNotExist
=
"El estudiante con Id de usuario: '{0}' no existe"
;
public
const
string
ProffesorDoesNotExist
=
"El profesor con Id de usuario: '{0}' no existe"
;
public
const
string
ForumDoesNotExist
=
"El foro con id '{0}' no existe"
;
public
const
string
DuplicateForumName
=
"Ya existe un foro con nombre '{0}'"
;
public
const
string
DuplicateForumUser
=
"El usuario '{0}' ya se encuentra matriculado al foro '{1}'"
;
public
const
string
PostDoesNotExist
=
"El post con id '{0}' no existe"
;
public
const
string
PostMessageDoesNotExist
=
"El mensage con id '{0}' no existe"
;
public
const
string
CannotConnectToSmtpServer
=
"No se pudo conectar al servidor SMTP"
;
public
const
string
CannotAuthenticateToSmtpServer
=
"No se pudo autenticar en el servidor SMTP"
;
public
const
string
CannotSendEmail
=
"No se pudo mandar el mail con asunto {0}"
;
public
const
string
CourseDoesNotExist
=
"El curso '{0}' no existe"
;
public
const
string
DuplicateCourseName
=
"Ya existe un curso con nombre '{0}'"
;
}
}
This diff is collapsed.
Click to expand it.
Tsi1.Api/Tsi1.BusinessLayer/Services/ForumService.cs
+
30
−
2
View file @
0b1cbe51
...
...
@@ -33,7 +33,17 @@ namespace Tsi1.BusinessLayer.Services
var
forum
=
_mapper
.
Map
<
Forum
>(
newForum
);
_context
.
Forums
.
Add
(
forum
);
await
_context
.
SaveChangesAsync
();
try
{
await
_context
.
SaveChangesAsync
();
}
catch
(
DbUpdateException
)
{
result
.
HasError
=
true
;
result
.
Message
=
string
.
Format
(
ErrorMessages
.
DuplicateForumName
,
newForum
.
Name
);
return
result
;
}
result
.
Data
=
forum
;
...
...
@@ -102,6 +112,15 @@ namespace Tsi1.BusinessLayer.Services
return
result
;
}
var
user
=
await
_context
.
Users
.
FirstOrDefaultAsync
(
x
=>
x
.
Id
==
userId
);
if
(
user
==
null
)
{
result
.
HasError
=
true
;
result
.
Message
=
string
.
Format
(
ErrorMessages
.
UserDoesNotExist
,
userId
);
return
result
;
}
var
forumUser
=
new
ForumUser
{
ForumId
=
forumId
,
...
...
@@ -110,7 +129,16 @@ namespace Tsi1.BusinessLayer.Services
_context
.
ForumUsers
.
Add
(
forumUser
);
await
_context
.
SaveChangesAsync
();
try
{
await
_context
.
SaveChangesAsync
();
}
catch
(
DbUpdateException
)
{
result
.
HasError
=
true
;
result
.
Message
=
string
.
Format
(
ErrorMessages
.
DuplicateForumUser
,
user
.
Username
,
forum
.
Name
);
return
result
;
}
return
result
;
}
...
...
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
register
or
sign in
to comment