Skip to content

Commit

Permalink
Fix bug (#111)
Browse files Browse the repository at this point in the history
* fix(Email) : change email body

* fix(Graph) : fix exception of file upload

* fix(user) : search for data analyze just
  • Loading branch information
mahdijafariii authored Sep 9, 2024
1 parent c7c37b7 commit 027463d
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 82 deletions.
10 changes: 3 additions & 7 deletions AnalysisData/AnalysisData.sln.DotSettings.user
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=098e78e2_002D707b_002D4922_002D926d_002Dcb148189e0cf/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="CheckExistenceOfRole_ShouldTNothrowRoleNotFoundException_WhenRoleExist" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Project Location="E:\CodeStar1403\Summer1403-Project-Group03-Backend\AnalysisData\TestProject" Presentation="&amp;lt;TestProject&amp;gt;" /&gt;&#xD;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=219940aa_002Df21c_002D44cf_002D9307_002Dab482de92a14/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="RoleRepositoryTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.RoleRepository.RoleRepositoryTests&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=219940aa_002Df21c_002D44cf_002D9307_002Dab482de92a14/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="RoleRepositoryTests" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Project Location="C:\Users\Mahdi\Desktop\code star proje\Summer1403-Project-Group03-Backend\AnalysisData\TestProject" Presentation="&amp;lt;TestProject&amp;gt;" /&gt;&#xD;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=5a6db5c4_002D6b10_002D4bf8_002D8325_002D71b5cea4c333/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="UpdateCategory_ShouldReturnOk_WhenCategoryIsUpdatedSuccessfully" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::9AEC1F3F-B1B3-47C1-82D4-E432E2D77E0E::net8.0::TestProject.User.Repository.UserRepository.UserRepositoryTests.GetUserByPhoneNumberAsync_ShouldReturnsNull_WhenUserWithInputPhoneNumberDoesNotExist&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
&lt;Project Location="C:\Users\Mahdi\Desktop\code star proje\Summer1403-Project-Group03-Backend\AnalysisData\TestProject" Presentation="&amp;lt;TestProject&amp;gt;" /&gt;&#xD;
&lt;/SessionState&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=fe4fe44b_002D7953_002D4423_002Dac04_002Da7f1b464e5c0/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" Name="ResetPasswordAsync_ShouldCallPasswordCheck_WhenCalled" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Project Location="E:\CodeStar1403\Summer1403-Project-Group03-Backend\AnalysisData\TestProject" Presentation="&amp;lt;TestProject&amp;gt;" /&gt;&#xD;
Expand Down
42 changes: 23 additions & 19 deletions AnalysisData/AnalysisData/Assets/email-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@
<tr>
<td class="pad">
<div align="right" class="alignment" style="line-height:10px">
<div style="max-width: 75px;"><a href="http://www.example.com/"
style="outline:none" tabindex="-1"
target="_blank"><img
<div style="max-width: 75px;"><a
href="https://myfronti.abriment.com/login"
style="outline:none" tabindex="-1"
target="_blank"><img
alt="Your Logo" height="auto"
src="https://i.postimg.cc/fybk9GG5/logo.png"
style="display: block; height: auto; border: 0; width: 100%;"
Expand All @@ -169,7 +170,7 @@
width="100%">
<tr>
<td class="pad">
<h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 40px; font-weight: 400; letter-spacing: normal; line-height: 120%; text-align: left; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 48px;">
<h3 style="margin: 0; color: #2c2c2c; direction: ltr; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 40px; font-weight: 400; letter-spacing: normal; line-height: 120%; text-align: left; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 48px;">
<span class="tinyMce-placeholder" style="word-break: break-word;">Star Data</span>
</h3>
</td>
Expand Down Expand Up @@ -288,16 +289,17 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
<div align="left" class="alignment"><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="urn:schemas-microsoft-com:office:word"
href="http://www.example.com/"
href="https://myfronti.abriment.com/login"
style="height:46px;width:212px;v-text-anchor:middle;"
arcsize="35%" stroke="false" fillcolor="#506bec">
<w:anchorlock/>
<v:textbox inset="5px,0,0,0">
<center dir="false"
style="color:#ffffff;font-family:Arial, sans-serif;font-size:15px">
<![endif]--><a href="{resetLink}"
style="background-color:#506bec;border-bottom:0 solid TRANSPARENT;border-left:0 solid TRANSPARENT;border-radius:16px;border-right:0 solid TRANSPARENT;border-top:0 solid TRANSPARENT;color:#ffffff;display:inline-block;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:15px;font-weight:undefined;mso-border-alt:none;padding-bottom:8px;padding-top:8px;text-align:center;text-decoration:none;width:auto;word-break:keep-all;"
target="_blank"><span
<![endif]--><a
href="https://myfronti.abriment.com?token={token}&email={email}"
style="background-color:#506bec;border-bottom:0 solid TRANSPARENT;border-left:0 solid TRANSPARENT;border-radius:16px;border-right:0 solid TRANSPARENT;border-top:0 solid TRANSPARENT;color:#ffffff;display:inline-block;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:15px;font-weight:undefined;mso-border-alt:none;padding-bottom:8px;padding-top:8px;text-align:center;text-decoration:none;width:auto;word-break:keep-all;"
target="_blank"><span
style="word-break: break-word; padding-left: 25px; padding-right: 20px; font-size: 15px; display: inline-block; letter-spacing: normal;"><span
style="word-break: break-word;"><span data-mce-style=""
style="word-break: break-word; line-height: 30px;"><strong>RESET PASSWORD</strong></span></span></span></a>
Expand All @@ -314,7 +316,7 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
<div style="color:#40507a;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;line-height:120%;text-align:left;mso-line-height-alt:17px;">
<p style="margin: 0; word-break: break-word;"><span
style="word-break: break-word;">Having trouble? <a
href="http://www.example.com/" rel="noopener"
href="https://myfronti.abriment.com/login" rel="noopener"
style="text-decoration: none; color: #40507a;"
target="_blank" title="@DataStarAdmin"><strong>@DataStarAdmin</strong></a></span>
</p>
Expand All @@ -328,9 +330,11 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
width="100%">
<tr>
<td class="pad">
<div style="color:#40507a;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;font-weight:700;line-height:120%;text-align:left;mso-line-height-alt:16.8px;">
<p style="margin: 0; word-break: break-word;">Didn't request a
password reset? You can ignore this message.</p>
<div style="color:#40507a;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;line-height:120%;text-align:left;mso-line-height-alt:16.8px;">
<span style="margin: 0; word-break: break-word; font-weight:500;">Didn't request a
password reset?</span>
<span style="margin: 0; word-break: break-word; font-weight:700">You can ignore this
message.</span>
</div>
</td>
</tr>
Expand Down Expand Up @@ -432,7 +436,7 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
<tr>
<td class="pad">
<div style="color:#97a2da;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;line-height:120%;text-align:center;mso-line-height-alt:16.8px;">
<p style="margin: 0; word-break: break-word;">+(98) 456–7890</p>
<p style="margin: 0; word-break: break-word;">+(98) 912-345-7890</p>
</div>
</td>
</tr>
Expand All @@ -445,8 +449,8 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
<td class="pad">
<div style="color:#97a2da;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;line-height:120%;text-align:center;mso-line-height-alt:17px;">
<p style="margin: 0; word-break: break-word;">This link will expire
in the next 24 hours.<br/>Please feel free to contact us at
email@yourbrand.com.</p>
in the next 15 minutes.<br/>Please feel free to contact us at
star.data.ad@gmail.com.</p>
</div>
</td>
</tr>
Expand All @@ -463,13 +467,13 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
</p>
<p style="margin: 0; word-break: break-word;"><span
style="word-break: break-word;"><a
href="http://www.example.com/" rel="noopener"
href="https://myfronti.abriment.com/login" rel="noopener"
style="text-decoration: underline; color: #97a2da;"
target="_blank" title="Unsubscribe ">Unsubscribe</a> | <a
href="http://www.example.com/" rel="noopener"
href="https://myfronti.abriment.com/login" rel="noopener"
style="text-decoration: underline; color: #97a2da;"
target="_blank" title="Manage your preferences">Manage your preferences</a> | <a
href="http://www.example.com/" rel="noopener"
href="https://myfronti.abriment.com/login" rel="noopener"
style="text-decoration: underline; color: #97a2da;"
target="_blank"
title="Privacy Policy">Privacy Policy</a></span></p>
Expand All @@ -490,4 +494,4 @@ <h3 style="margin: 0; color: #1e0e4b; direction: ltr; font-family: Helvetica Neu
</tbody>
</table><!-- End -->
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public async Task<IActionResult> UploadNodeFile([FromForm] NodeUploadDto nodeUpl

return Ok(new
{
message = "File uploaded successfully!"
message = "nodes saved successfully in the database."
});
}
catch (System.Exception e)
{
return StatusCode(400, $"An error occurred while processing the file: {e.Message}");
throw new FileProcessingException(e.Message);
}
}

Expand All @@ -79,7 +79,7 @@ public async Task<IActionResult> UploadEdgeFile([FromForm] EdgeUploadDto edgeUpl
}
catch (System.Exception e)
{
return StatusCode(400, $"An error occurred while processing the file: {e.Message}");
throw new FileProcessingException(e.Message);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace AnalysisData.Exception.FileException;

public class FileProcessingException : ServiceException
{
public FileProcessingException(string missingHeaders)
: base(string.Format(Resources.FileProcessingException, string.Join(", ", missingHeaders)), StatusCodes.Status404NotFound)
{
}
}
9 changes: 9 additions & 0 deletions AnalysisData/AnalysisData/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AnalysisData/AnalysisData/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@
<data name="AdminProtectedException" xml:space="preserve">
<value>You can not delete or modify admin information !</value>
</data>
<data name="FileProcessingException" xml:space="preserve">
<value>failed to processing file ! </value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public async Task SendPasswordResetEmail(string toEmail, string resetLink, strin

string htmlTemplatePath = @"Assets\email-template.html";
string htmlContent = File.ReadAllText(htmlTemplatePath);
string linkWithToken = $"{resetLink}&token={token}$email={toEmail}";
htmlContent = htmlContent.Replace("{resetLink}", linkWithToken);
string linkWithToken = $"{resetLink}?token={token}&email={toEmail}";
htmlContent = htmlContent.Replace("https://myfronti.abriment.com?token={token}&email={email}", linkWithToken);

var mailMessage = new MailMessage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public async Task SendRequestToResetPassword(string email)
}

var token = await _jwtService.RequestResetPassword(user);
await _emailService.SendPasswordResetEmail(user.Email, "www.digikala.com",token);
await _emailService.SendPasswordResetEmail(user.Email, "https://myfronti.abriment.com",token);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task GetAllRoles_ShouldReturnPaginationRolesList_WhenRolesExist()
var roles = new List<RolePaginationDto>
{
new(){Name = "admin",Policy = "gold"},
new(){Name = "dataanalyst",Policy = "silver"}
new(){Name = "data-analyst",Policy = "silver"}
};
var page = 0;
var limit = 10;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using AnalysisData.Data;
using AnalysisData.Models.UserModel;
using AnalysisData.Repositories.RoleRepository;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace TestProject.User.Repository.RoleRepository;

public class RoleRepositoryTests
{
private readonly AnalysisData.Repositories.RoleRepository.RoleRepository _sut;
private readonly RoleRepository _sut;
private readonly ServiceProvider _serviceProvider;

public RoleRepositoryTests()
Expand All @@ -20,7 +20,7 @@ public RoleRepositoryTests()
serviceCollection.AddScoped(_ => new ApplicationDbContext(options));
_serviceProvider = serviceCollection.BuildServiceProvider();

_sut = new AnalysisData.Repositories.RoleRepository.RoleRepository(CreateDbContext());
_sut = new RoleRepository(CreateDbContext());
}

private ApplicationDbContext CreateDbContext()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using AnalysisData.Data;
using AnalysisData.Models.UserModel;
using AnalysisData.Repositories.UserRepository;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace TestProject.User.Repository.UserRepository;

public class UserRepositoryTests
{
private readonly ServiceProvider _serviceProvider;
private readonly AnalysisData.Repositories.UserRepository.UserRepository _sut;
private readonly UserRepository _sut;

public UserRepositoryTests()
{
Expand All @@ -19,7 +19,7 @@ public UserRepositoryTests()
var serviceCollection = new ServiceCollection();
serviceCollection.AddScoped(_ => new ApplicationDbContext(options));
_serviceProvider = serviceCollection.BuildServiceProvider();
_sut = new AnalysisData.Repositories.UserRepository.UserRepository(CreateDbContext());
_sut = new UserRepository(CreateDbContext());
}

private ApplicationDbContext CreateDbContext()
Expand Down
Loading

0 comments on commit 027463d

Please sign in to comment.