School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class AccountController : Controller
{
private readonly IRepoInterface<Account> _accountRepo;
public AccountController(IRepoInterface<Account> accountRepo)
{
_accountRepo = accountRepo;
}
[HttpGet(Name = "GetAllAccounts")]
public IActionResult GetAll()
{
try
{
return Ok(_accountRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "AccountGetById")]
[ProducesResponseType(200, Type = typeof(Account))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_accountRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddAccount")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] Account account)
{
try
{
_accountRepo.Add(account);
return CreatedAtRoute("AccountGetById", new { id = account.Id }, account);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateAccount")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] Account account)
{
try
{
_accountRepo.Update(account);
return Ok(account);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteAccount")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_accountRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class BlockedProfileController : Controller
{
private readonly IRepoInterface<BlockedProfile> _blockedProfileRepo;
public BlockedProfileController(IRepoInterface<BlockedProfile> blockedProfileRepo)
{
_blockedProfileRepo = blockedProfileRepo;
}
[HttpGet(Name = "GetAllBlockedProfiles")]
public IActionResult GetAll()
{
try
{
return Ok(_blockedProfileRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "BlockedProfileGetById")]
[ProducesResponseType(200, Type = typeof(BlockedProfile))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_blockedProfileRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddBlockedProfile")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] BlockedProfile blockedProfile)
{
try
{
_blockedProfileRepo.Add(blockedProfile);
return CreatedAtRoute("BlockedProfileGetById", new { id = blockedProfile.Id }, blockedProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateBlockedProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] BlockedProfile blockedProfile)
{
try
{
_blockedProfileRepo.Update(blockedProfile);
return Ok(blockedProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteBlockedProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_blockedProfileRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class CloseFriendsProfileController : Controller
{
private readonly IRepoInterface<CloseFriendProfile> _closeFriendsProfileRepo;
public CloseFriendsProfileController(IRepoInterface<CloseFriendProfile> closeFriendsProfileRepo)
{
_closeFriendsProfileRepo = closeFriendsProfileRepo;
}
[HttpGet(Name = "GetAllCloseFriendsProfiles")]
public IActionResult GetAll()
{
try
{
return Ok(_closeFriendsProfileRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "CloseFriendsProfileGetById")]
[ProducesResponseType(200, Type = typeof(CloseFriendProfile))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_closeFriendsProfileRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddCloseFriendsProfile")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] CloseFriendProfile closeFriendProfile)
{
try
{
_closeFriendsProfileRepo.Add(closeFriendProfile);
return CreatedAtRoute("CloseFriendsProfileGetById", new { id = closeFriendProfile.Id }, closeFriendProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateCloseFriendsProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] CloseFriendProfile closeFriendProfile)
{
try
{
_closeFriendsProfileRepo.Update(closeFriendProfile);
return Ok(closeFriendProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteCloseFriendsProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_closeFriendsProfileRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class FancierProfileController : Controller
{
private readonly IRepoInterface<FancierProfile> _fancierProfileRepo;
public FancierProfileController(IRepoInterface<FancierProfile> fancierProfileRepo)
{
_fancierProfileRepo = fancierProfileRepo;
}
[HttpGet(Name = "GetAllFancierProfiles")]
public IActionResult GetAll()
{
try
{
return Ok(_fancierProfileRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "FancierProfileGetById")]
[ProducesResponseType(200, Type = typeof(FancierProfile))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_fancierProfileRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddFancierProfile")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] FancierProfile fancierProfile)
{
try
{
_fancierProfileRepo.Add(fancierProfile);
return CreatedAtRoute("FancierProfileGetById", new { id = fancierProfile.ProfileId }, fancierProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateFancierProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] FancierProfile fancierProfile)
{
try
{
_fancierProfileRepo.Update(fancierProfile);
return Ok(fancierProfile);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteFancierProfile")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_fancierProfileRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class GroupController : Controller
{
private readonly IRepoInterface<Group> _groupRepo;
public GroupController(IRepoInterface<Group> groupRepo)
{
_groupRepo = groupRepo;
}
[HttpGet(Name = "GetAllGroups")]
public IActionResult GetAll()
{
try
{
return Ok(_groupRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "GroupGetById")]
[ProducesResponseType(200, Type = typeof(Group))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_groupRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddGroup")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] Group group)
{
try
{
_groupRepo.Add(group);
return CreatedAtRoute("GroupGetById", new { id = group.Id }, group);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateGroup")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] Group group)
{
try
{
_groupRepo.Update(group);
return Ok(group);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteGroup")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_groupRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,93 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class HighlightController : Controller
{
private readonly IRepoInterface<Highlight> _highlightRepo;
public HighlightController(IRepoInterface<Highlight> highlightRepo)
{
_highlightRepo = highlightRepo;
}
[HttpGet(Name = "GetAllHighlights")]
public IActionResult GetAll()
{
try
{
return Ok(_highlightRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "HighlightGetById")]
[ProducesResponseType(200, Type = typeof(Highlight))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_highlightRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddHighlight")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] Highlight highlight)
{
try
{
_highlightRepo.Add(highlight);
return CreatedAtRoute("HighlightGetById", new { id = highlight.HighlightId }, highlight);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateHighlight")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] Highlight highlight)
{
try
{
_highlightRepo.Update(highlight);
return Ok(highlight);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteHighlight")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_highlightRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,95 @@
using Microsoft.AspNetCore.Mvc;
using District3API.domain;
using District3API.RepoInterfaces;
namespace District3API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class UserController : Controller
{
private readonly IRepoInterface<User> _userRepo;
public UserController(IRepoInterface<User> userRepo)
{
_userRepo = userRepo;
}
[HttpGet(Name = "GetAllUsers")]
public IActionResult GetAll()
{
try
{
return Ok(_userRepo.GetAll());
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpGet("{id}", Name = "UserGetById")]
[ProducesResponseType(200, Type = typeof(User))]
[ProducesResponseType(400)]
public IActionResult GetById(int id)
{
try
{
return Ok(_userRepo.GetById(id));
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPost(Name = "AddUser")]
[ProducesResponseType(201)]
[ProducesResponseType(400)]
public IActionResult Add([FromBody] User user)
{
try
{
_userRepo.Add(user);
return CreatedAtRoute("GetById", new { id = user.Id }, user);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpPut(Name = "UpdateUser")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Update([FromBody] User user)
{
try
{
_userRepo.Update(user);
return Ok(user);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
[HttpDelete("{id}", Name = "DeleteUser")]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult Delete([FromRoute] int id)
{
try
{
_userRepo.Delete(id);
return NoContent();
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
}
}
@@ -0,0 +1,69 @@
using District3API.domain;
namespace District3API.DataBaseContext;
using Microsoft.EntityFrameworkCore;
public class DataContext: DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
public DbSet<Account> Account { get; set; }
public DbSet<BlockedProfile> BlockedProfile { get; set; }
public DbSet<CloseFriendProfile> CloseFriendProfile { get; set; }
public DbSet<FancierProfile>? FancierProfile { get; set; }
public DbSet<Group> Group { get; set; }
public DbSet<Highlight> Highlight { get; set; }
public DbSet<Post> Post { get; set; }
public DbSet<User> User { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Account>(account =>
{
account.HasKey(e => e.Id);
account.HasOne(e => e.User)
.WithOne()
.HasForeignKey<Account>(e => e.UserId)
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity<BlockedProfile>(blockedProfile =>
{
blockedProfile.HasKey(e => e.Id);
blockedProfile.HasOne(e => e.User)
.WithOne()
.HasForeignKey<BlockedProfile>(e => e.UserId)
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity<CloseFriendProfile>(closeFriendProfile =>
{
closeFriendProfile.HasKey(e => e.Id);
closeFriendProfile.HasOne(e => e.User)
.WithOne()
.HasForeignKey<CloseFriendProfile>(e => e.UserId)
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity<FancierProfile>().HasKey(x => x.ProfileId);
modelBuilder.Entity<Group>(group =>
{
group.HasKey(e => e.Id);
});
modelBuilder.Entity<Highlight>(highlight =>
{
highlight.HasKey(e => e.HighlightId);
highlight.HasOne(e => e.User)
.WithMany()
.HasForeignKey(e => e.UserId);
});
modelBuilder.Entity<Post>().HasKey(x => x.Id);
modelBuilder.Entity<User>(user =>
{
user.HasKey(e => e.Id);
user.HasOne(e => e.Group)
.WithMany(g => g.GroupMembers)
.HasForeignKey(e => e.GroupId);
});
}
}
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>
</Project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
</PropertyGroup>
</Project>
@@ -0,0 +1,6 @@
@District3API_HostAddress = http://localhost:5284
GET {{District3API_HostAddress}}/weatherforecast/
Accept: application/json
###
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore;
using District3API.DataBaseContext;
using District3API.domain;
using District3API.RepoInterfaces;
using District3API.Repos;
namespace District3API
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddDbContextFactory<DataContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
builder.Services.AddScoped<IRepoInterface<Account>, AccountRepository>();
builder.Services.AddScoped<IRepoInterface<BlockedProfile>, BlockedProfileRepository>();
builder.Services.AddScoped<IRepoInterface<CloseFriendProfile>, CloseFriendsProfileRepository>();
builder.Services.AddScoped<IRepoInterface<FancierProfile>, FancierProfileRepository>();
// TODO: I do not understand why this below is not working
builder.Services.AddScoped<IRepoInterface<Group>, GroupRepository>();
builder.Services.AddScoped<IRepoInterface<Highlight>, HighlightRepository>();
builder.Services.AddScoped<IRepoInterface<Post>, PostRepository>();
builder.Services.AddScoped<IRepoInterface<User>, UserRepository>();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:34839",
"sslPort": 44370
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7261;http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,11 @@
namespace District3API.RepoInterfaces
{
public interface IRepoInterface<T>
{
public T GetById(int id);
public ICollection<T> GetAll();
public void Add(T item);
public void Update(T item);
public void Delete(int id);
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class AccountRepository : IRepoInterface<Account>
{
private readonly DataContext _context;
public AccountRepository(DataContext context)
{
_context = context;
}
public void Add(Account item)
{
_context.Account.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var account = _context.Account.Find(id);
if (account != null)
{
_context.Account.Remove(account);
_context.SaveChanges();
}
}
public ICollection<Account> GetAll()
{
return _context.Account.ToList();
}
public Account GetById(int id)
{
return _context.Account.Find(id);
}
public void Update(Account item)
{
_context.Account.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class BlockedProfileRepository : IRepoInterface<BlockedProfile>
{
private readonly DataContext _context;
public BlockedProfileRepository(DataContext context)
{
_context = context;
}
public void Add(BlockedProfile item)
{
_context.BlockedProfile.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var blockedProfile = _context.BlockedProfile.Find(id);
if (blockedProfile != null)
{
_context.BlockedProfile.Remove(blockedProfile);
_context.SaveChanges();
}
}
public ICollection<BlockedProfile> GetAll()
{
return _context.BlockedProfile.ToList();
}
public BlockedProfile GetById(int id)
{
return _context.BlockedProfile.Find(id);
}
public void Update(BlockedProfile item)
{
_context.BlockedProfile.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class CloseFriendsProfileRepository : IRepoInterface<CloseFriendProfile>
{
private readonly DataContext _context;
public CloseFriendsProfileRepository(DataContext context)
{
_context = context;
}
public void Add(CloseFriendProfile item)
{
_context.CloseFriendProfile.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var closeFriendProfile = _context.CloseFriendProfile.Find(id);
if (closeFriendProfile != null)
{
_context.CloseFriendProfile.Remove(closeFriendProfile);
_context.SaveChanges();
}
}
public ICollection<CloseFriendProfile> GetAll()
{
return _context.CloseFriendProfile.ToList();
}
public CloseFriendProfile GetById(int id)
{
return _context.CloseFriendProfile.Find(id);
}
public void Update(CloseFriendProfile item)
{
_context.CloseFriendProfile.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class FancierProfileRepository : IRepoInterface<FancierProfile>
{
private readonly DataContext _context;
public FancierProfileRepository(DataContext context)
{
_context = context;
}
public void Add(FancierProfile item)
{
_context.FancierProfile.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var fancierProfile = _context.FancierProfile.Find(id);
if (fancierProfile != null)
{
_context.FancierProfile.Remove(fancierProfile);
_context.SaveChanges();
}
}
public ICollection<FancierProfile> GetAll()
{
return _context.FancierProfile.ToList();
}
public FancierProfile GetById(int id)
{
return _context.FancierProfile.Find(id);
}
public void Update(FancierProfile item)
{
_context.FancierProfile.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class GroupRepository : IRepoInterface<Group>
{
private readonly DataContext _context;
public GroupRepository(DataContext context)
{
_context = context;
}
public void Add(Group item)
{
_context.Group.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var group = _context.Group.Find(id);
if (group != null)
{
_context.Group.Remove(group);
_context.SaveChanges();
}
}
public ICollection<Group> GetAll()
{
return _context.Group.ToList();
}
public Group GetById(int id)
{
return _context.Group.Find(id);
}
public void Update(Group item)
{
_context.Group.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class HighlightRepository : IRepoInterface<Highlight>
{
private readonly DataContext _context;
public HighlightRepository(DataContext context)
{
_context = context;
}
public void Add(Highlight item)
{
_context.Highlight.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var highlight = _context.Highlight.Find(id);
if (highlight != null)
{
_context.Highlight.Remove(highlight);
_context.SaveChanges();
}
}
public ICollection<Highlight> GetAll()
{
return _context.Highlight.ToList();
}
public Highlight GetById(int id)
{
return _context.Highlight.Find(id);
}
public void Update(Highlight item)
{
_context.Highlight.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class PostRepository : IRepoInterface<Post>
{
private readonly DataContext _context;
public PostRepository(DataContext context)
{
_context = context;
}
public void Add(Post item)
{
_context.Post.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var post = _context.Post.Find(id);
if (post != null)
{
_context.Post.Remove(post);
_context.SaveChanges();
}
}
public ICollection<Post> GetAll()
{
return _context.Post.ToList();
}
public Post GetById(int id)
{
return _context.Post.Find(id);
}
public void Update(Post item)
{
_context.Post.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,48 @@
using District3API.domain;
using District3API.DataBaseContext;
using District3API.RepoInterfaces;
namespace District3API.Repos
{
public class UserRepository : IRepoInterface<User>
{
private readonly DataContext _context;
public UserRepository(DataContext context)
{
_context = context;
}
public void Add(User item)
{
_context.User.Add(item);
_context.SaveChanges();
}
public void Delete(int id)
{
var user = _context.User.Find(id);
if (user != null)
{
_context.User.Remove(user);
_context.SaveChanges();
}
}
public ICollection<User> GetAll()
{
return _context.User.ToList();
}
public User GetById(int id)
{
return _context.User.Find(id);
}
public void Update(User item)
{
_context.User.Update(item);
_context.SaveChanges();
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,12 @@
{
"ConnectionStrings": {
"DefaultConnection": "Data Source = VLAD-LEGIO-5PRO\\SQLEXPRESS01; Initial Catalog = iss_vlad3; Integrated Security = true; Connect Timeout=30;Encrypt=True;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
namespace District3API.domain
{
public class Account
{
public int Id { get; set; }
public string? CardNumber { get; set; }
public string? HolderName { get; set; }
public string? ExpirationDate{ get; set; }
public string? Cvv { get; set; }
public int UserId { get; set; }
[JsonIgnore]
public User? User { get; set; }
}
}
@@ -0,0 +1,14 @@
using System.Text.Json.Serialization;
namespace District3API.domain;
public class BlockedProfile
{
public int Id { get; set; }
public int UserId { get; set; }
[JsonIgnore]
public User? User { get; set; }
public DateTime BlockDate { get; set; }
}
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;
namespace District3API.domain;
public class CloseFriendProfile
{
public int Id { get; set; }
public int UserId { get; set; }
[JsonIgnore]
public User? User { get; set; }
public DateTime CloseFriendedDate { get; set; }
}
@@ -0,0 +1,11 @@
namespace District3API.domain;
public class FancierProfile
{
public int ProfileId { get; set; }
public List<string>? Links { get; set; }
public string? DailyMotto { get; set; }
public DateTime? RemoveMottoDate { get; set; }
public int FrameNumber { get; set; }
public string? Hashtag { get; set; }
}
@@ -0,0 +1,11 @@
namespace District3API.domain
{
public class Group
{
public int Id { get; set; }
public string? GroupName { get; set; }
public List<User>? GroupMembers { get; set; }
}
}
@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
namespace District3API.domain
{
public class Highlight
{
public int HighlightId { get; set; }
public int UserId { get; set; }
[JsonIgnore]
public User? User { get; set; }
public List<int>? PostsIds { get; set; }
public string? Name { get; set; }
public string? CoverFilePath { get; set; }
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace District3API.domain
{
public class Post
{
public int Id { get; set; }
}
}
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;
namespace District3API.domain
{
public class User
{
public int Id { get; set; }
public string? Username { get; set; }
public string? Password { get; set; }
public string? Email { get; set; }
public string? ConfirmationPassword { get; set; }
public DateTime RegistrationDate { get; set; }
public int FollowingCount { get; set; }
public int FollowersCount { get; set; }
[JsonIgnore]
public TimeSpan UserSession { get; set; }
public int GroupId { get; set; }
public Group? Group { get; set; }
}
}