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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Hort Daniel/L01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
L01 SaaS
========
**Youtube** e un serviciu de distribuire de continut video-audio
care se incadreaza la definitia unui SaaS deoarece ai nevoie
doar de un cont de utilizator si eventual de un cont in banca
daca nu iti plac reclamele si nu ai auzit inca de AdBlock.
25 changes: 25 additions & 0 deletions Hort Daniel/L02/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
25 changes: 25 additions & 0 deletions Hort Daniel/L02/L02.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31613.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L02", "L02\L02.csproj", "{A771835E-F29E-43FB-9C31-2A15D769AFAC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A771835E-F29E-43FB-9C31-2A15D769AFAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A771835E-F29E-43FB-9C31-2A15D769AFAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A771835E-F29E-43FB-9C31-2A15D769AFAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A771835E-F29E-43FB-9C31-2A15D769AFAC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0395D628-F9CD-4BC9-A420-D3C21FBE0B0B}
EndGlobalSection
EndGlobal
56 changes: 56 additions & 0 deletions Hort Daniel/L02/L02/Controllers/StudentsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using L02.Models;
using L02.Services;
using LanguageExt;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace L02.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class StudentsController : ControllerBase
{
private readonly StudentRepo repo;

public StudentsController(StudentRepo repo)
{
this.repo = repo;
}

[HttpGet]
public async Task<IActionResult> Get()
=> Ok(repo.Get());

[HttpGet("{id}")]
public async Task<IActionResult> Get(
[FromRoute] int id)
=> repo.Get(a => a.Id == a.Id).Case switch
{
SomeCase<Student> s => Ok(s.Value),
NoneCase<Student> _ => NotFound()
};

[HttpPost]
public async Task<IActionResult> Add(
[FromBody] Student student)
=> repo.Add(student) switch
{
true => Ok(),
false => BadRequest($"Student with id:{{{student.Id}}} already exists.")
};

[HttpPut]
public async Task<IActionResult> Update(
[FromBody] Student student)
=> Ok(repo.Update(student));

[HttpDelete("{id}")]
public async Task<IActionResult> Delete(
[FromRoute] int id)
=> Ok(repo.Delete(a => a.Id == id));
}
}
22 changes: 22 additions & 0 deletions Hort Daniel/L02/L02/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["L02/L02.csproj", "L02/"]
RUN dotnet restore "L02/L02.csproj"
COPY . .
WORKDIR "/src/L02"
RUN dotnet build "L02.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "L02.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "L02.dll"]
15 changes: 15 additions & 0 deletions Hort Daniel/L02/L02/L02.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>af3dfcca-cb4f-4bbc-876b-df1e6d46321d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LanguageExt.Core" Version="3.4.15" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions Hort Daniel/L02/L02/Models/Student.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace L02.Models
{
public class Student
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Faculty { get; set; }
public int YearOfStudy { get; set; }
}
}
26 changes: 26 additions & 0 deletions Hort Daniel/L02/L02/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace L02
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
38 changes: 38 additions & 0 deletions Hort Daniel/L02/L02/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:1879",
"sslPort": 44301
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"L02": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": "true",
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
}
}
47 changes: 47 additions & 0 deletions Hort Daniel/L02/L02/Services/StudentRepo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using L02.Models;
using LanguageExt;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace L02.Services
{
public class StudentRepo
{
private IEnumerable<Student> students;

public StudentRepo()
{
students = Enumerable.Empty<Student>();
}

public Option<Student> Get(Func<Student, bool> predicate)
=> students.FirstOrDefault(predicate);

public IEnumerable<Student> Get()
=> students.OrderBy(a => a.Id);

public bool Add(Student student)
{
var exists = students.Any(a => a.Id == student.Id);
if (exists)
return false;
students = students.Append(student);
return true;
}

public Unit Update(Student student)
{
students = students.Where(a => a.Id != student.Id).Append(student);
return Unit.Default;
}

public Unit Delete(Func<Student, bool> predicate)
{
students = students.Where(a => !predicate.Invoke(a));
return Unit.Default;
}
}
}
60 changes: 60 additions & 0 deletions Hort Daniel/L02/L02/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using L02.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace L02
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<StudentRepo>(a => new StudentRepo());
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "L02", Version = "v1" });
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "L02 v1"));
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
9 changes: 9 additions & 0 deletions Hort Daniel/L02/L02/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
10 changes: 10 additions & 0 deletions Hort Daniel/L02/L02/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
25 changes: 25 additions & 0 deletions Hort Daniel/L03/L03.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31613.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L03", "L03\L03.csproj", "{3841303C-4C25-4823-B190-D45BCFF2CC73}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3841303C-4C25-4823-B190-D45BCFF2CC73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3841303C-4C25-4823-B190-D45BCFF2CC73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3841303C-4C25-4823-B190-D45BCFF2CC73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3841303C-4C25-4823-B190-D45BCFF2CC73}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AFDE35EE-8925-480A-82F2-83EC86839376}
EndGlobalSection
EndGlobal
Loading