Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<Properties StartupConfiguration="{98D81E2C-901F-4790-A00E-CA0AC63E431F}|Default">
<MonoDevelop.Ide.Workbench ActiveDocument="Controllers/BooksController.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="appsettings.json">
<Files>
<File FileName="Startup.cs" Line="52" Column="28" />
<File FileName="Program.cs" />
<File FileName="Repositories/IBooksRepository.cs" />
<File FileName="Dtos/BookDto.cs" />
<File FileName="Repositories/Extensions.cs" />
<File FileName="Dtos/CreateBookDto.cs" />
<File FileName="Repositories/MongoDbBooksRepository.cs" />
<File FileName="MongoDbSettings/MongoDbSettings.cs" />
<File FileName="Properties/launchSettings.json" />
<File FileName="Startup.cs" Line="22" Column="1" />
<File FileName="Program.cs" Line="1" Column="1" />
<File FileName="Repositories/IBooksRepository.cs" Line="1" Column="1" />
<File FileName="Dtos/BookDto.cs" Line="1" Column="1" />
<File FileName="Repositories/Extensions.cs" Line="1" Column="1" />
<File FileName="Dtos/CreateBookDto.cs" Line="1" Column="1" />
<File FileName="Repositories/MongoDbBooksRepository.cs" Line="52" Column="13" />
<File FileName="MongoDbSettings/MongoDbSettings.cs" Line="1" Column="1" />
<File FileName="Properties/launchSettings.json" Line="1" Column="1" />
<File FileName="Controllers/BooksController.cs" Line="1" Column="28" />
<File FileName="Models/OwnerClass.cs" Line="1" Column="1" />
<File FileName="Models/Book.cs" Line="1" Column="1" />
<File FileName="appsettings.Development.json" Line="1" Column="1" />
<File FileName="appsettings.json" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="MongoBookApis" expanded="True">
<Node name="MongoBookApis" expanded="True">
<Node name="Controllers" expanded="True">
<Node name="BooksController.cs" selected="True" />
</Node>
<Node name="Controllers" expanded="True" />
<Node name="Dtos" expanded="True" />
<Node name="Models" expanded="True" />
<Node name="MongoDbSettings" expanded="True" />
<Node name="Properties" expanded="True" />
<Node name="Repositories" expanded="True" />
<Node name="appsettings.json" expanded="True" />
<Node name="appsettings.json" expanded="True" selected="True" />
</Node>
</Node>
</State>
Expand All @@ -47,8 +49,8 @@
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
<Breakpoint enabled="false" file="/Users/hanieharabzadeh/Desktop/Developments/C#/Mongo/BookstoreAPIs/MongoBookApis/Repositories/MongoDbBooksRepository.cs" relfile="Repositories/MongoDbBooksRepository.cs" line="24" column="1" />
<Breakpoint enabled="false" file="/Users/hanieharabzadeh/Desktop/Developments/C#/Mongo/BookstoreAPIs/MongoBookApis/Startup.cs" relfile="Startup.cs" line="42" column="17" />
<Breakpoint enabled="false" file="/Users/hanieharabzadeh/Desktop/Developments/C#/Mongo/BookstoreAPIs/MongoBookApis/Startup.cs" relfile="Startup.cs" line="38" column="13" />
<Breakpoint enabled="false" file="/Users/hanieharabzadeh/Desktop/Developments/C#/Mongo/BookstoreAPIs/MongoBookApis/Startup.cs" relfile="Startup.cs" line="43" column="17" />
<Breakpoint enabled="false" file="/Users/hanieharabzadeh/Desktop/Developments/C#/Mongo/BookstoreAPIs/MongoBookApis/Startup.cs" relfile="Startup.cs" line="39" column="13" />
</BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using MongoBookApis.Repositories;
using MongoBookApis.Dtos;
using System.Threading.Tasks;
using System.Web.Http.Cors;

namespace MongoBookApis.Controllers
{
[ApiController]
[Route("books")]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class BooksController : ControllerBase
{

Expand All @@ -22,6 +24,7 @@ public BooksController(IBooksRepository _repository)
}
// GET /books
[HttpGet]
[EnableCors(origins: "*", headers: "*", methods: "*")]
public async Task<IEnumerable<BookDto>> GetBooksAsync()
{
var books = (await repository.GetBooksAsync())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="MongoDB.Driver" Version="2.13.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Cors" Version="5.2.7" />
</ItemGroup>

<ItemGroup>
Expand All @@ -15,6 +16,7 @@
<None Remove="Repositories\" />
<None Remove="Dtos\" />
<None Remove="MongoDbSettings\" />
<None Remove="Microsoft.AspNet.WebApi.Cors" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\" />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ public async Task<IEnumerable<Book>> SearchAsync(string title = "", string autho
var titleFilter = filterBuiler.Regex(book => book.Title, "/.*" + title + ".*/");
var authorsFilter = filterBuiler.Regex(book => book.Authors, "/.*" + authors + ".*/");
var minNumPageFilter = filterBuiler.Gt(book => book.NumPage, minNumPage);
Console.WriteLine(maxNumPage);

if (minNumPage == "" || minNumPage == null)
{
minNumPageFilter = filterBuiler.Gt(book => book.NumPage, "0");
}
var maxNumPageFilter = filterBuiler.Lt(book => book.NumPage, maxNumPage);
if (maxNumPage == "" || maxNumPage == null)
{
Console.WriteLine("yes");
maxNumPageFilter = filterBuiler.Lt(book => book.NumPage, double.PositiveInfinity.ToString());
}

Expand Down
16 changes: 15 additions & 1 deletion MongoBookApis/Startup.cs → Back-end/MongoBookApis/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using MongoDB.Bson;
using MongoDB.Driver.Core.Operations;


namespace MongoBookApis
{
public class Startup
Expand All @@ -43,6 +44,19 @@ public void ConfigureServices(IServiceCollection services)
var client = new MongoClient(settings.ConnectionString);
return client;
});
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";



//services.AddCors(options =>
//{
// options.AddPolicy(name: MyAllowSpecificOrigins,
// builder =>
// {
// builder.WithOrigins("http://localhost:3000" ,
// "https://localhost:3000");
// });
//});
services.AddSingleton<IBooksRepository, MongoDbBooksRepository>();

services.AddControllers(options => {
Expand All @@ -65,7 +79,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MongoBookApis v1"));
}

app.UseHttpsRedirection();

app.UseRouting();
Expand Down
File renamed without changes.
Loading