Skip to content

Commit

Permalink
Save changes in styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcanosantana committed Nov 27, 2023
1 parent dec6371 commit e8215bf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
45 changes: 45 additions & 0 deletions Pages/Dashboard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,40 @@
</div>
</div>

<!-- Save changes -->
<div class="col-12 col-xl-6">
<div class="container py-4 jumbotron-a">

<div class="container">
<div class="row">

<div class="col-12 col-md-4">
<h3 class="fw-bold">Guardar</h3>
<p>
Guarda los cambios realizados.
</p>
</div>

<div class="col-12 col-md-8">

<div class="mb-3">
<button @onclick="() => NavigationManager.NavigateTo(GetAbsoluteUri())" class="btn btn-outline-light">
Ver invitación
</button>

<button @onclick="() => SaveCurrentStyle()" class="btn button-gold-a">
Guardar estilo
</button>
</div>

</div>

</div>
</div>

</div>
</div>

</div>
</div>

Expand All @@ -154,6 +188,17 @@
SetCustomStyle();
}

private void SaveCurrentStyle()
{
UserService.SaveStyle(
UserService.GetLoggedUser().GetId(),

Check warning on line 194 in Pages/Dashboard.razor

View workflow job for this annotation

GitHub Actions / deploy-to-github-pages

Dereference of a possibly null reference.
customTitle,
customDescription,
customBackground,
customAvatar
);
}

private void SetCustomStyle()
{
customStyle = UserService.GetAffiliateStyle(UserService.GetLoggedUser().GetId());

Check warning on line 204 in Pages/Dashboard.razor

View workflow job for this annotation

GitHub Actions / deploy-to-github-pages

Dereference of a possibly null reference.
Expand Down
19 changes: 18 additions & 1 deletion Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public Tuple<bool, String> TryRegisterUser(User user)

return new Tuple<bool, string>(true, "Registro completado!");
}

public Tuple<bool, String> TryLoginUser(String mail, String password) {

if (String.IsNullOrEmpty(mail))
Expand All @@ -112,6 +111,24 @@ public Tuple<bool, String> TryLoginUser(String mail, String password) {
return new Tuple<bool, string>(true, "Sesión iniciada!");
}

//Styles functions
public void SaveStyle(String uid, String title, String summary, String backgroundUrl, String avatarUrl)
{
AffiliateStyle newStyle = new AffiliateStyle(
uid, title, summary, backgroundUrl, avatarUrl
);

//If already exists, replace, if not, create
int index = dummyStylesDatabase.FindIndex(style => style.GetAffiliateUid() == uid);

//Does not exist
if (index == -1)
dummyStylesDatabase.Add(newStyle);
//Else replace
else
dummyStylesDatabase[index] = newStyle;
}


//Tools
private static bool IsMailValid(String email)
Expand Down

0 comments on commit e8215bf

Please sign in to comment.