cleanup
This commit is contained in:
parent
07d5954fa8
commit
372ec741dd
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"devToolsPort": 19002
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"hostType": "lan",
|
||||
"lanType": "ip",
|
||||
"dev": true,
|
||||
"minify": false,
|
||||
"urlRandomness": null
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
#DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
// Use IntelliSense to find out which attributes exist for C# debugging
|
||||
// Use hover for the description of the existing attributes
|
||||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (web)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/api.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
"launchBrowser": {
|
||||
"enabled": true,
|
||||
"args": "${auto-detect-url}",
|
||||
"windows": {
|
||||
"command": "cmd.exe",
|
||||
"args": "/C start ${auto-detect-url}"
|
||||
},
|
||||
"osx": {
|
||||
"command": "open"
|
||||
},
|
||||
"linux": {
|
||||
"command": "xdg-open"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
,]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "process",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/api.csproj"
|
||||
],
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using api.Dtos;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AdminController : ControllerBase
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public AdminController(DataContext context, UserManager<User> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
|
||||
[Authorize(Policy= "RequireAdminRole")]
|
||||
[HttpGet("userWithRoles")]
|
||||
public async Task<IActionResult> GetUsersWithRole() {
|
||||
|
||||
var userList= await (from user in _context.Users orderby user.UserName
|
||||
select new{
|
||||
Id = user.Id,
|
||||
UserName= user.UserName,
|
||||
Roles = (from userRole in user.UserRoles join role in _context.Roles
|
||||
on userRole.RoleId
|
||||
equals role.Id
|
||||
select role.Name).ToList()
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
return Ok(userList);
|
||||
}
|
||||
|
||||
[Authorize(Policy= "RequireAdminRole")]
|
||||
[HttpPost("editRoles/{userName}")]
|
||||
public async Task<IActionResult> editRoles(string userName, RoleEditDto roleEditDto) {
|
||||
|
||||
var user = await _userManager.FindByNameAsync(userName);
|
||||
|
||||
var userRoles = await _userManager.GetRolesAsync(user);
|
||||
|
||||
var selectedRoles = roleEditDto.RoleNames;
|
||||
|
||||
//selected = selectedRoles != null ? selectedRoles : new String[] {}
|
||||
selectedRoles = selectedRoles ?? new string[] {};
|
||||
|
||||
var result= await _userManager.AddToRolesAsync(user, selectedRoles.Except(userRoles));
|
||||
|
||||
if(!result.Succeeded)
|
||||
return BadRequest("Falha ao adicionar roles");
|
||||
|
||||
result = await _userManager.RemoveFromRolesAsync(user, userRoles.Except(selectedRoles));
|
||||
|
||||
if(!result.Succeeded)
|
||||
return BadRequest("Falha ao remover as roles");
|
||||
|
||||
return Ok(await _userManager.GetRolesAsync(user));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Dtos;
|
||||
using api.Models;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[AllowAnonymous]
|
||||
[Route("api/")]
|
||||
[ApiController]
|
||||
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly IConfiguration config;
|
||||
public UserManager<User> _userManager { get; }
|
||||
public SignInManager<User> _signInManager { get; }
|
||||
public IUsersRepository _repo { get; }
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
private readonly RoleManager<Role> _roleManager;
|
||||
|
||||
public AuthController(IConfiguration config, UserManager<User> UserManager, SignInManager<User> SignInManager, IMapper mapper, RoleManager<Role> roleManager, IUsersRepository repo)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_roleManager = roleManager;
|
||||
_repo = repo;
|
||||
this.config = config;
|
||||
_userManager = UserManager;
|
||||
_signInManager = SignInManager;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("register")]
|
||||
public async Task<IActionResult> Register(UserForRegisterDto userToRegister)
|
||||
{
|
||||
var userToCreate = _mapper.Map<User>(userToRegister);
|
||||
|
||||
var result = await _userManager.CreateAsync(userToCreate, userToRegister.password);
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
return StatusCode(201);
|
||||
}
|
||||
return BadRequest(result.Errors);
|
||||
|
||||
}
|
||||
[HttpPost("login")]
|
||||
public async Task<IActionResult> Login(UserForLoginDto UserForLoginDto)
|
||||
{
|
||||
//retorno 500
|
||||
var user = await _userManager.FindByNameAsync(UserForLoginDto.Username);
|
||||
|
||||
|
||||
var result = await _signInManager.CheckPasswordSignInAsync(user, UserForLoginDto.Password, false);
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
var appUser = await _userManager.Users.FirstOrDefaultAsync(u => u.NormalizedUserName == UserForLoginDto.Username.ToUpper());
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
|
||||
token = GenerateJwtToken(appUser).Result
|
||||
});
|
||||
|
||||
}
|
||||
return Unauthorized();
|
||||
|
||||
}
|
||||
|
||||
private async Task<string> GenerateJwtToken(User user)
|
||||
{
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
|
||||
new Claim(ClaimTypes.Name, user.UserName)
|
||||
};
|
||||
|
||||
var roles = await _userManager.GetRolesAsync(user);
|
||||
|
||||
foreach(var role in roles) {
|
||||
claims.Add(new Claim(ClaimTypes.Role,role));
|
||||
}
|
||||
|
||||
//obtem a key na app settings
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config.GetSection("AppSettings:Token").Value));
|
||||
|
||||
//faz hashing da key na app settings
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);
|
||||
|
||||
//criamos um token
|
||||
var tokenDescriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
Subject = new ClaimsIdentity(claims),
|
||||
//data de expiração (atual + 24 horas)
|
||||
Expires = DateTime.Now.AddDays(1),
|
||||
|
||||
//passa as signing credentials definidas em cima
|
||||
SigningCredentials = creds
|
||||
};
|
||||
|
||||
//criamos um token handler
|
||||
var tokenHandler = new JwtSecurityTokenHandler();
|
||||
|
||||
//em seguida criamos o token
|
||||
var token = tokenHandler.CreateToken(tokenDescriptor);
|
||||
|
||||
return tokenHandler.WriteToken(token);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace api.Controllers
|
||||
{
|
||||
public class TalksController
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Dtos;
|
||||
using api.Models;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly IUsersRepository _repo;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly RoleManager<Role> _roleManager;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public UsersController(IUsersRepository repo, IMapper mapper,RoleManager<Role> roleManager,UserManager<User> UserManager)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_roleManager = roleManager;
|
||||
_userManager = UserManager;
|
||||
_repo = repo;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetUser(int id)
|
||||
{
|
||||
|
||||
var user = await _repo.GetUser(id);
|
||||
|
||||
var userToReturn = _mapper.Map<UserForDetailedDto>(user);
|
||||
|
||||
return Ok(userToReturn);
|
||||
|
||||
}
|
||||
|
||||
[Authorize(Policy= "RequireAdminRole")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetUsers()
|
||||
{
|
||||
var users = await _repo.GetUsers();
|
||||
|
||||
var usersToReturn = _mapper.Map<IEnumerable<UserForListDto>>(users);
|
||||
|
||||
return Ok(usersToReturn);
|
||||
}
|
||||
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> UpdateUser(int id, UserForUpdateDto userForUpdate){
|
||||
|
||||
if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
|
||||
return Unauthorized(); //garante que é o próprio pode aceder à sua informação
|
||||
|
||||
var userFromRepo = await _repo.GetUser(id);
|
||||
|
||||
_mapper.Map(userForUpdate, userFromRepo);
|
||||
|
||||
if(await _repo.SaveAll())
|
||||
return NoContent();
|
||||
|
||||
throw new System.Exception($"updating user {id} failed on save");
|
||||
}
|
||||
|
||||
|
||||
[HttpPut("update/{id}")]
|
||||
[Authorize(Policy= "RequireAdminRole")]
|
||||
public async Task<IActionResult> UpdateUserById(int id, UserForUpdateDto userForUpdate){
|
||||
|
||||
var userFromRepo = await _repo.GetUser(id);
|
||||
|
||||
_mapper.Map(userForUpdate, userFromRepo);
|
||||
|
||||
if(await _repo.SaveAll())
|
||||
return NoContent();
|
||||
|
||||
throw new System.Exception($"updating user {id} failed on save");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//adiciona uma nova role à base de dados
|
||||
[Authorize(Policy= "RequireAdminRole")]
|
||||
[HttpPost("addRole")]
|
||||
public IActionResult addRole( Role role) {
|
||||
|
||||
_roleManager.CreateAsync(role).Wait();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ValuesController : ControllerBase
|
||||
{
|
||||
private readonly DataContext context;
|
||||
public ValuesController(DataContext context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
// GET api/values
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetValues()
|
||||
{
|
||||
var values= await context.Values.ToListAsync();
|
||||
return Ok(values);
|
||||
}
|
||||
|
||||
// GET api/values/5
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetValue(int id)
|
||||
{
|
||||
//procura o primeiro ou o default (que é null)
|
||||
var value= await context.Values.FirstOrDefaultAsync(x => x.id == id);
|
||||
|
||||
return Ok(value);
|
||||
}
|
||||
|
||||
// POST api/values
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/values/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using api.Dtos;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("/")]
|
||||
public class mvcController : Controller
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
private readonly UserManager<User> _userManager;
|
||||
|
||||
public mvcController(DataContext context, UserManager<User> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult landingPage() {
|
||||
|
||||
return View("Views/Landing/index.cshtml");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
using api.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public class AuthRepository : IAuthRepository
|
||||
{
|
||||
public AuthRepository(DataContext context)
|
||||
{
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public DataContext Context { get; }
|
||||
|
||||
public async Task<User> Login(string username, string password)
|
||||
{
|
||||
|
||||
var user =await Context.Users.FirstOrDefaultAsync(x=> x.UserName== username);
|
||||
|
||||
if(user==null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
public async Task<User> Register(User user, string Password)
|
||||
{
|
||||
await Context.Users.AddAsync(user);
|
||||
|
||||
await Context.SaveChangesAsync();
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
using api.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public class DataContext : IdentityDbContext<User,Role,int,IdentityUserClaim<int>,
|
||||
UserRole,IdentityUserLogin<int>,IdentityRoleClaim<int>,IdentityUserToken<int>>
|
||||
{
|
||||
public DataContext(DbContextOptions<DataContext> options):base(options) { }
|
||||
|
||||
public DbSet<Value> Values{get;set;}
|
||||
|
||||
public DbSet<Photo> Photos {get;set;}
|
||||
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
|
||||
//para o ef saber as relações
|
||||
builder.Entity<UserRole>(userRole =>
|
||||
{
|
||||
userRole.HasKey(ur=> new {ur.UserId, ur.RoleId});
|
||||
|
||||
userRole.HasOne( ur=>ur.Role)
|
||||
.WithMany(r=>r.UserRoles)
|
||||
.HasForeignKey(ur=> ur.RoleId)
|
||||
.IsRequired();
|
||||
|
||||
|
||||
userRole.HasOne( ur=>ur.User)
|
||||
.WithMany(r=>r.UserRoles)
|
||||
.HasForeignKey(ur=> ur.UserId)
|
||||
.IsRequired();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public interface IAuthRepository
|
||||
{
|
||||
|
||||
Task<User> Register(User user, string Password);
|
||||
|
||||
Task<User> Login(string username, string password);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
|
||||
public interface IUsersRepository
|
||||
{
|
||||
void Add<T>(T enity) where T: class;
|
||||
void Delete<T>(T entity) where T: class;
|
||||
Task<bool> SaveAll();
|
||||
Task<IEnumerable<User>> GetUsers();
|
||||
Task<User> GetUser(int id);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public class UsersRepository : IUsersRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
public UsersRepository(DataContext context)
|
||||
{
|
||||
this._context = context;
|
||||
}
|
||||
public void Add<T>(T enity) where T : class
|
||||
{
|
||||
_context.Add(enity);
|
||||
|
||||
}
|
||||
|
||||
public void Delete<T>(T entity) where T : class
|
||||
{
|
||||
|
||||
_context.Remove(entity);
|
||||
}
|
||||
|
||||
public async Task<User> GetUser(int id)
|
||||
{
|
||||
var user = await _context.Users.Include(p=>p.Photos).FirstOrDefaultAsync(u=>u.Id==id);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>> GetUsers()
|
||||
{
|
||||
var users= await _context.Users.Include(p=>p.Photos).ToListAsync();
|
||||
|
||||
return users;
|
||||
}
|
||||
|
||||
public async Task<bool> SaveAll()
|
||||
{
|
||||
return await _context.SaveChangesAsync()>0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace api.Dtos
|
||||
{
|
||||
public class PhotosForDetailedDto
|
||||
{
|
||||
public int Id{get;set;}
|
||||
public string Url{get;set;}
|
||||
public string Description{get;set;}
|
||||
public DateTime DateAdded{get;set;}
|
||||
public bool IsMain{get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace api.Dtos
|
||||
{
|
||||
public class RoleEditDto
|
||||
{
|
||||
public string[] RoleNames { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace api.Dtos
|
||||
{
|
||||
public class UserForDetailedDto
|
||||
{
|
||||
public string FullName {get;set;}
|
||||
public int Id{get;set;}
|
||||
public string Username{get;set;}
|
||||
public string Gender {get;set;}
|
||||
public int Age{get;set;}
|
||||
public int Phone{get;set;}
|
||||
public string University{get;set;}
|
||||
public string Adress{get;set;}
|
||||
public string Country{get;set;}
|
||||
public string City{get;set;}
|
||||
public string linkedIn{get;set;}
|
||||
public DateTime LastLogin {get;set;}
|
||||
public DateTime Registed{get;set;}
|
||||
public string QRcode{get;set;}
|
||||
public string Role{get;set;}
|
||||
public string Degree{get;set;}
|
||||
public int SchoolYear{get;set;}
|
||||
public string ProfileIcon {get;set;}
|
||||
public string Company{get;set;}
|
||||
public string Position{get;set;}
|
||||
public string About{get;set;}
|
||||
public ICollection<PhotosForDetailedDto> Photos {get;set;}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace api.Dtos
|
||||
{
|
||||
public class UserForListDto
|
||||
{
|
||||
public int Id{get;set;}
|
||||
public string Username{get;set;}
|
||||
public string FullName {get;set;}
|
||||
public string Gender {get;set;}
|
||||
public int Age{get;set;}
|
||||
public int Phone{get;set;}
|
||||
public string University{get;set;}
|
||||
public string Adress{get;set;}
|
||||
public string linkedIn{get;set;}
|
||||
public string QRcode{get;set;}
|
||||
public string Degree{get;set;}
|
||||
public string ProfileIcon {get;set;}
|
||||
public string About{get;set;}
|
||||
public string PhotoUrl{get;set;}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace api.Dtos
|
||||
{
|
||||
public class UserForLoginDto
|
||||
{
|
||||
public string Username{get;set;}
|
||||
public string Password{get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Dtos
|
||||
{
|
||||
public class UserForRegisterDto
|
||||
{
|
||||
[Required]
|
||||
public string username {get;set;}
|
||||
|
||||
[Required]
|
||||
[StringLength(15,MinimumLength=4,ErrorMessage="You must specify password between 4 and 15 cars")]
|
||||
public string password{get;set;}
|
||||
public string fullname {get;set;}
|
||||
public string gender {get;set;}
|
||||
public int age{get;set;}
|
||||
public int phone{get;set;}
|
||||
public string email{get;set;}
|
||||
public string university{get;set;}
|
||||
public string adress{get;set;}
|
||||
public string country{get;set;}
|
||||
public string city{get;set;}
|
||||
public string linkedin{get;set;}
|
||||
public DateTime lastlogin {get;set;}
|
||||
public DateTime registed{get;set;}
|
||||
public string qrcode{get;set;}
|
||||
public string role{get;set;}
|
||||
public string degree{get;set;}
|
||||
public int schoolyear{get;set;}
|
||||
public string profileicon {get;set;}
|
||||
public string company{get;set;}
|
||||
public string position{get;set;}
|
||||
public string about{get;set;}
|
||||
public ICollection<Photo> Photos{get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace api.Dtos
|
||||
{
|
||||
public class UserForUpdateDto
|
||||
{
|
||||
public string about{get;set;}
|
||||
public string university{get;set;}
|
||||
public string degree{get;set;}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace api.Dtos
|
||||
{
|
||||
public class setRoleDto
|
||||
{
|
||||
public int Id{get;set;}
|
||||
public string RoleName{get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using api.Dtos;
|
||||
using api.Models;
|
||||
using AutoMapper;
|
||||
|
||||
namespace api.Helpers
|
||||
{
|
||||
public class AutoMapperProfiles: Profile
|
||||
{
|
||||
public AutoMapperProfiles()
|
||||
{
|
||||
CreateMap<UserForRegisterDto,User>();
|
||||
CreateMap<User,UserForListDto>();
|
||||
CreateMap<User, UserForDetailedDto>();
|
||||
CreateMap<Photo,PhotosForDetailedDto>();
|
||||
CreateMap<UserForUpdateDto,User>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace api.Helpers
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static void AddApplicationError(this HttpResponse response, string message)
|
||||
{
|
||||
response.Headers.Add("Application-Error",message);
|
||||
response.Headers.Add("Access-Control-Expose-Headers","Application-Error");
|
||||
response.Headers.Add("Access-Control-Allow-Origin","*");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using api.Data;
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataContext))]
|
||||
[Migration("20180829184152_update")]
|
||||
partial class update
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846");
|
||||
|
||||
modelBuilder.Entity("api.Models.Photo", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("DateAdded");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<bool>("IsMain");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Photos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("About");
|
||||
|
||||
b.Property<int>("AccessFailedCount");
|
||||
|
||||
b.Property<string>("Adress");
|
||||
|
||||
b.Property<int>("Age");
|
||||
|
||||
b.Property<string>("City");
|
||||
|
||||
b.Property<string>("Company");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Country");
|
||||
|
||||
b.Property<string>("Degree");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<bool>("EmailConfirmed");
|
||||
|
||||
b.Property<string>("FullName");
|
||||
|
||||
b.Property<string>("Gender");
|
||||
|
||||
b.Property<DateTime>("LastLogin");
|
||||
|
||||
b.Property<bool>("LockoutEnabled");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("PasswordHash");
|
||||
|
||||
b.Property<int>("Phone");
|
||||
|
||||
b.Property<string>("PhoneNumber");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed");
|
||||
|
||||
b.Property<string>("Position");
|
||||
|
||||
b.Property<string>("ProfileIcon");
|
||||
|
||||
b.Property<string>("QRcode");
|
||||
|
||||
b.Property<DateTime>("Registed");
|
||||
|
||||
b.Property<string>("Role");
|
||||
|
||||
b.Property<int>("SchoolYear");
|
||||
|
||||
b.Property<string>("SecurityStamp");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled");
|
||||
|
||||
b.Property<string>("University");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("linkedIn");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.UserRole", b =>
|
||||
{
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.Property<int>("RoleId");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Value", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Values");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<int>("RoleId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("ProviderKey");
|
||||
|
||||
b.Property<string>("ProviderDisplayName");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Photo", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User", "User")
|
||||
.WithMany("Photos")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.UserRole", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Role", "Role")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("api.Models.User", "User")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
public partial class update : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetRoles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(maxLength: 256, nullable: true),
|
||||
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
|
||||
ConcurrencyStamp = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetUsers",
|
||||
columns: table => new
|
||||
{
|
||||
AccessFailedCount = table.Column<int>(nullable: false),
|
||||
EmailConfirmed = table.Column<bool>(nullable: false),
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
LockoutEnabled = table.Column<bool>(nullable: false),
|
||||
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
|
||||
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
|
||||
TwoFactorEnabled = table.Column<bool>(nullable: false),
|
||||
UserName = table.Column<string>(maxLength: 256, nullable: true),
|
||||
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
|
||||
Email = table.Column<string>(maxLength: 256, nullable: true),
|
||||
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
|
||||
PasswordHash = table.Column<string>(nullable: true),
|
||||
SecurityStamp = table.Column<string>(nullable: true),
|
||||
ConcurrencyStamp = table.Column<string>(nullable: true),
|
||||
PhoneNumber = table.Column<string>(nullable: true),
|
||||
FullName = table.Column<string>(nullable: true),
|
||||
Gender = table.Column<string>(nullable: true),
|
||||
Age = table.Column<int>(nullable: false),
|
||||
Phone = table.Column<int>(nullable: false),
|
||||
University = table.Column<string>(nullable: true),
|
||||
Adress = table.Column<string>(nullable: true),
|
||||
Country = table.Column<string>(nullable: true),
|
||||
City = table.Column<string>(nullable: true),
|
||||
linkedIn = table.Column<string>(nullable: true),
|
||||
LastLogin = table.Column<DateTime>(nullable: false),
|
||||
Registed = table.Column<DateTime>(nullable: false),
|
||||
QRcode = table.Column<string>(nullable: true),
|
||||
Role = table.Column<string>(nullable: true),
|
||||
Degree = table.Column<string>(nullable: true),
|
||||
SchoolYear = table.Column<int>(nullable: false),
|
||||
ProfileIcon = table.Column<string>(nullable: true),
|
||||
Company = table.Column<string>(nullable: true),
|
||||
Position = table.Column<string>(nullable: true),
|
||||
About = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Values",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Values", x => x.id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetRoleClaims",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
RoleId = table.Column<int>(nullable: false),
|
||||
ClaimType = table.Column<string>(nullable: true),
|
||||
ClaimValue = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "AspNetRoles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetUserClaims",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
UserId = table.Column<int>(nullable: false),
|
||||
ClaimType = table.Column<string>(nullable: true),
|
||||
ClaimValue = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetUserLogins",
|
||||
columns: table => new
|
||||
{
|
||||
LoginProvider = table.Column<string>(nullable: false),
|
||||
ProviderKey = table.Column<string>(nullable: false),
|
||||
ProviderDisplayName = table.Column<string>(nullable: true),
|
||||
UserId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetUserRoles",
|
||||
columns: table => new
|
||||
{
|
||||
RoleId = table.Column<int>(nullable: false),
|
||||
UserId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
||||
column: x => x.RoleId,
|
||||
principalTable: "AspNetRoles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AspNetUserTokens",
|
||||
columns: table => new
|
||||
{
|
||||
UserId = table.Column<int>(nullable: false),
|
||||
LoginProvider = table.Column<string>(nullable: false),
|
||||
Name = table.Column<string>(nullable: false),
|
||||
Value = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
||||
table.ForeignKey(
|
||||
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Photos",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Url = table.Column<string>(nullable: true),
|
||||
Description = table.Column<string>(nullable: true),
|
||||
DateAdded = table.Column<DateTime>(nullable: false),
|
||||
IsMain = table.Column<bool>(nullable: false),
|
||||
UserId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Photos", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Photos_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetRoleClaims_RoleId",
|
||||
table: "AspNetRoleClaims",
|
||||
column: "RoleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "RoleNameIndex",
|
||||
table: "AspNetRoles",
|
||||
column: "NormalizedName",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetUserClaims_UserId",
|
||||
table: "AspNetUserClaims",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetUserLogins_UserId",
|
||||
table: "AspNetUserLogins",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AspNetUserRoles_RoleId",
|
||||
table: "AspNetUserRoles",
|
||||
column: "RoleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "EmailIndex",
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedEmail");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "UserNameIndex",
|
||||
table: "AspNetUsers",
|
||||
column: "NormalizedUserName",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Photos_UserId",
|
||||
table: "Photos",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetRoleClaims");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUserClaims");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUserLogins");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUserRoles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUserTokens");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Photos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Values");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetRoles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AspNetUsers");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,300 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using api.Data;
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
[DbContext(typeof(DataContext))]
|
||||
partial class DataContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.1-rtm-30846");
|
||||
|
||||
modelBuilder.Entity("api.Models.Photo", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("DateAdded");
|
||||
|
||||
b.Property<string>("Description");
|
||||
|
||||
b.Property<bool>("IsMain");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Photos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Role", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedName")
|
||||
.IsUnique()
|
||||
.HasName("RoleNameIndex");
|
||||
|
||||
b.ToTable("AspNetRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("About");
|
||||
|
||||
b.Property<int>("AccessFailedCount");
|
||||
|
||||
b.Property<string>("Adress");
|
||||
|
||||
b.Property<int>("Age");
|
||||
|
||||
b.Property<string>("City");
|
||||
|
||||
b.Property<string>("Company");
|
||||
|
||||
b.Property<string>("ConcurrencyStamp")
|
||||
.IsConcurrencyToken();
|
||||
|
||||
b.Property<string>("Country");
|
||||
|
||||
b.Property<string>("Degree");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<bool>("EmailConfirmed");
|
||||
|
||||
b.Property<string>("FullName");
|
||||
|
||||
b.Property<string>("Gender");
|
||||
|
||||
b.Property<DateTime>("LastLogin");
|
||||
|
||||
b.Property<bool>("LockoutEnabled");
|
||||
|
||||
b.Property<DateTimeOffset?>("LockoutEnd");
|
||||
|
||||
b.Property<string>("NormalizedEmail")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("NormalizedUserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("PasswordHash");
|
||||
|
||||
b.Property<int>("Phone");
|
||||
|
||||
b.Property<string>("PhoneNumber");
|
||||
|
||||
b.Property<bool>("PhoneNumberConfirmed");
|
||||
|
||||
b.Property<string>("Position");
|
||||
|
||||
b.Property<string>("ProfileIcon");
|
||||
|
||||
b.Property<string>("QRcode");
|
||||
|
||||
b.Property<DateTime>("Registed");
|
||||
|
||||
b.Property<string>("Role");
|
||||
|
||||
b.Property<int>("SchoolYear");
|
||||
|
||||
b.Property<string>("SecurityStamp");
|
||||
|
||||
b.Property<bool>("TwoFactorEnabled");
|
||||
|
||||
b.Property<string>("University");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.HasMaxLength(256);
|
||||
|
||||
b.Property<string>("linkedIn");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("NormalizedEmail")
|
||||
.HasName("EmailIndex");
|
||||
|
||||
b.HasIndex("NormalizedUserName")
|
||||
.IsUnique()
|
||||
.HasName("UserNameIndex");
|
||||
|
||||
b.ToTable("AspNetUsers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.UserRole", b =>
|
||||
{
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.Property<int>("RoleId");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetUserRoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Value", b =>
|
||||
{
|
||||
b.Property<int>("id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("Values");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<int>("RoleId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("AspNetRoleClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("ClaimType");
|
||||
|
||||
b.Property<string>("ClaimValue");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("ProviderKey");
|
||||
|
||||
b.Property<string>("ProviderDisplayName");
|
||||
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("AspNetUserLogins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId");
|
||||
|
||||
b.Property<string>("LoginProvider");
|
||||
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("AspNetUserTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Photo", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User", "User")
|
||||
.WithMany("Photos")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.UserRole", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Role", "Role")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("api.Models.User", "User")
|
||||
.WithMany("UserRoles")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Role")
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.HasOne("api.Models.User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
|
||||
namespace api.Models
|
||||
|
||||
{
|
||||
public class Photo
|
||||
{
|
||||
public int Id{get;set;}
|
||||
|
||||
public string Url {get;set;}
|
||||
|
||||
public string Description{get;set;}
|
||||
public DateTime DateAdded {get;set;}
|
||||
public bool IsMain {get;set;}
|
||||
public User User{get;set;}
|
||||
public int UserId{get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace api.Models
|
||||
{
|
||||
public class Role : IdentityRole <int>
|
||||
{
|
||||
|
||||
public ICollection<UserRole> UserRoles{get;set;}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace api.Models
|
||||
|
||||
{
|
||||
public class User: IdentityUser<int>
|
||||
{
|
||||
|
||||
public string FullName {get;set;}
|
||||
public string Gender {get;set;}
|
||||
public int Age{get;set;}
|
||||
public int Phone{get;set;}
|
||||
public string University{get;set;}
|
||||
public string Adress{get;set;}
|
||||
public string Country{get;set;}
|
||||
public string City{get;set;}
|
||||
public string linkedIn{get;set;}
|
||||
public DateTime LastLogin {get;set;}
|
||||
public DateTime Registed{get;set;}
|
||||
public string QRcode{get;set;}
|
||||
public string Role{get;set;}
|
||||
public string Degree{get;set;}
|
||||
public int SchoolYear{get;set;}
|
||||
public string ProfileIcon {get;set;}
|
||||
public string Company{get;set;}
|
||||
public string Position{get;set;}
|
||||
public string About{get;set;}
|
||||
public ICollection<UserRole> UserRoles{get;set;}
|
||||
public ICollection<Photo> Photos {get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace api.Models
|
||||
{
|
||||
public class UserRole: IdentityUserRole<int>
|
||||
{
|
||||
public User User{get;set;}
|
||||
|
||||
public Role Role{get;set;}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
namespace api.Models
|
||||
{
|
||||
public class Value
|
||||
{
|
||||
public int id{get;set;}
|
||||
|
||||
public string Name{ get;set;}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace api
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:40138",
|
||||
"sslPort": 44339
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/values",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"api": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/values",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Helpers;
|
||||
using api.Models;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace api
|
||||
{
|
||||
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.AddAutoMapper();
|
||||
services.AddScoped<IUsersRepository, UsersRepository>();
|
||||
|
||||
//define a connection string indicada em appsettings.json
|
||||
services.AddDbContext<DataContext>(x=>x.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
|
||||
|
||||
IdentityBuilder builder = services.AddIdentityCore<User>(Options=>
|
||||
{
|
||||
//mudar isto no fim por questoes de segurança
|
||||
Options.Password.RequireDigit = false;
|
||||
Options.Password.RequiredLength=4;
|
||||
Options.Password.RequireNonAlphanumeric= false;
|
||||
Options.Password.RequireUppercase= false;
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
builder= new IdentityBuilder(builder.UserType,typeof(Role),builder.Services);
|
||||
|
||||
builder.AddEntityFrameworkStores<DataContext>();
|
||||
|
||||
builder.AddRoleValidator<RoleValidator<Role>>();
|
||||
|
||||
builder.AddRoleManager<RoleManager<Role>>();
|
||||
|
||||
builder.AddSignInManager<SignInManager<User>>();
|
||||
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options=> {
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
|
||||
ValidateIssuer = false,
|
||||
ValidateAudience= false,
|
||||
};
|
||||
});
|
||||
|
||||
services.AddAuthorization(options => {
|
||||
options.AddPolicy("RequireAdminRole",policy => policy.RequireRole("Admin"));
|
||||
//adicionar mais roles aqui
|
||||
});
|
||||
|
||||
services.AddMvc(Options=>
|
||||
{
|
||||
var policy= new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
|
||||
Options.Filters.Add(new AuthorizeFilter(policy));
|
||||
|
||||
}
|
||||
).
|
||||
SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
||||
|
||||
//cors support
|
||||
services.AddCors();
|
||||
services.AddMvc();
|
||||
//autenticação para o token
|
||||
|
||||
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
app.UseStaticFiles();
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
//globar exception handler
|
||||
app.UseExceptionHandler(builder => {
|
||||
|
||||
builder.Run(async context => {
|
||||
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
var error= context.Features.Get<IExceptionHandlerFeature>();
|
||||
|
||||
if(error!= null){
|
||||
context.Response.AddApplicationError(error.Error.Message);
|
||||
await context.Response.WriteAsync(error.Error.Message);
|
||||
}
|
||||
});
|
||||
});
|
||||
// app.UseHsts();
|
||||
}
|
||||
|
||||
// app.UseHttpsRedirection();
|
||||
|
||||
//cores supporte
|
||||
app.UseCors(x=>x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
||||
app.UseAuthentication();
|
||||
app.UseMvc();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
lols
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1"/>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"AppSettings":
|
||||
{
|
||||
"Token":"NbTSjGOaBMfweUyCvINv23Tt9jHhiEz2MBcYrYPhd24xWsztIV3bgDGOsWfRJFb8"
|
||||
},
|
||||
"ConnectionStrings":
|
||||
{
|
||||
"DefaultConnection":"Data Source= api.db"
|
||||
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"additionalProbingPaths": [
|
||||
"/Users/henrique/.dotnet/store/|arch|/|tfm|",
|
||||
"/Users/henrique/.nuget/packages",
|
||||
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "netcoreapp2.1",
|
||||
"framework": {
|
||||
"name": "Microsoft.AspNetCore.All",
|
||||
"version": "2.1.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.GC.Server": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#pragma checksum "/Users/henrique/enei2019/api/Views/Landing/index.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "058baae9cf1000caeb9e952d0edeadb354ed197a"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Landing_index), @"mvc.1.0.view", @"/Views/Landing/index.cshtml")]
|
||||
[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Landing/index.cshtml", typeof(AspNetCore.Views_Landing_index))]
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
[global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"058baae9cf1000caeb9e952d0edeadb354ed197a", @"/Views/Landing/index.cshtml")]
|
||||
public class Views_Landing_index : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(0, 4, true);
|
||||
WriteLiteral("lols");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
|
@ -0,0 +1,16 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("api")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("api")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("api")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
|
@ -0,0 +1 @@
|
|||
9f2c22d9dbbfb3187a717a253ae3cd497f2f7c77
|
|
@ -0,0 +1 @@
|
|||
be6c2f1957e37581aa7c268c3491629cc5b53cc0
|
|
@ -0,0 +1,13 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("api.Views")]
|
||||
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")]
|
||||
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")]
|
||||
[assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")]
|
|
@ -0,0 +1 @@
|
|||
b1c0bc83eea2b41751e683db0712e4ce1877a8d2
|
|
@ -0,0 +1 @@
|
|||
f371bf350f1693230a2f85e8f0a8e7cb3e2deca4
|
|
@ -0,0 +1,18 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute("Microsoft.AspNetCore.Mvc.ApplicationParts.CompiledRazorAssemblyApplicationPartFac" +
|
||||
"tory, Microsoft.AspNetCore.Mvc.Razor")]
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("api")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("api")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("api.Views")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
a5985a8ca0d535f2c38a42924fdb5866272e2868
|
|
@ -0,0 +1,23 @@
|
|||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.deps.json
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.runtimeconfig.json
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.runtimeconfig.dev.json
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.dll
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.pdb
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.csprojAssemblyReference.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.csproj.CoreCompileInputs.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.RazorAssemblyInfo.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.RazorAssemblyInfo.cs
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.AssemblyInfoInputs.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.AssemblyInfo.cs
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.RazorTargetAssemblyInfo.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.dll
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.pdb
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.Views.dll
|
||||
/Users/henrique/enei2019/api/bin/Debug/netcoreapp2.1/api.Views.pdb
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.TagHelpers.input.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.TagHelpers.output.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.RazorCoreGenerate.cache
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/Razor/Views/Landing/index.g.cshtml.cs
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.RazorTargetAssemblyInfo.cs
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.Views.pdb
|
||||
/Users/henrique/enei2019/api/obj/Debug/netcoreapp2.1/api.csproj.CopyComplete
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"ProjectFilePath": "/Users/henrique/enei2019/api/api.csproj",
|
||||
"TargetFramework": "netcoreapp2.1",
|
||||
"TagHelpers": [],
|
||||
"Configuration": {
|
||||
"ConfigurationName": "MVC-2.1",
|
||||
"LanguageVersion": "2.1",
|
||||
"Extensions": [
|
||||
{
|
||||
"ExtensionName": "MVC-2.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="GetEFProjectMetadata" Condition="">
|
||||
<MSBuild Condition=" '$(TargetFramework)' == '' "
|
||||
Projects="$(MSBuildProjectFile)"
|
||||
Targets="GetEFProjectMetadata"
|
||||
Properties="TargetFramework=$(TargetFrameworks.Split(';')[0]);EFProjectMetadataFile=$(EFProjectMetadataFile)" />
|
||||
<ItemGroup Condition=" '$(TargetFramework)' != '' ">
|
||||
<EFProjectMetadata Include="AssemblyName: $(AssemblyName)" />
|
||||
<EFProjectMetadata Include="Language: $(Language)" />
|
||||
<EFProjectMetadata Include="OutputPath: $(OutputPath)" />
|
||||
<EFProjectMetadata Include="Platform: $(Platform)" />
|
||||
<EFProjectMetadata Include="PlatformTarget: $(PlatformTarget)" />
|
||||
<EFProjectMetadata Include="ProjectAssetsFile: $(ProjectAssetsFile)" />
|
||||
<EFProjectMetadata Include="ProjectDir: $(ProjectDir)" />
|
||||
<EFProjectMetadata Include="RootNamespace: $(RootNamespace)" />
|
||||
<EFProjectMetadata Include="RuntimeFrameworkVersion: $(RuntimeFrameworkVersion)" />
|
||||
<EFProjectMetadata Include="TargetFileName: $(TargetFileName)" />
|
||||
<EFProjectMetadata Include="TargetFrameworkMoniker: $(TargetFrameworkMoniker)" />
|
||||
</ItemGroup>
|
||||
<WriteLinesToFile Condition=" '$(TargetFramework)' != '' "
|
||||
File="$(EFProjectMetadataFile)"
|
||||
Lines="@(EFProjectMetadata)" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"version": 1,
|
||||
"dgSpecHash": "WgSIDO2aNXJM3+NVsQN85bnSYTnN+GLKLvAZ05u5LdW96kSbgEgrqrUsZF3u6AYOsqfgGrFItAR2SJyFsa6KKA==",
|
||||
"success": true
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/Users/henrique/enei2019/api/obj/project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/henrique/.nuget/packages/</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/henrique/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.7.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<Import Project="/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.netcore.app/2.1.0/build/netcoreapp2.1/Microsoft.NETCore.App.props" Condition="Exists('/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.netcore.app/2.1.0/build/netcoreapp2.1/Microsoft.NETCore.App.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.fileproviders.embedded/2.1.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.fileproviders.embedded/2.1.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets/2.1.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets/2.1.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.entityframeworkcore.design/2.1.0/build/netcoreapp2.0/Microsoft.EntityFrameworkCore.Design.props" Condition="Exists('$(NuGetPackageRoot)microsoft.entityframeworkcore.design/2.1.0/build/netcoreapp2.0/Microsoft.EntityFrameworkCore.Design.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.extensions/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.extensions/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.razor.design/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.razor.design/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Razor.Design.props')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.all/2.1.0/build/netcoreapp2.1/Microsoft.AspNetCore.All.props" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.all/2.1.0/build/netcoreapp2.1/Microsoft.AspNetCore.All.props')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<Import Project="/usr/local/share/dotnet/sdk/NuGetFallbackFolder/netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets" Condition="Exists('/usr/local/share/dotnet/sdk/NuGetFallbackFolder/netstandard.library/2.0.3/build/netstandard2.0/NETStandard.Library.targets')" />
|
||||
<Import Project="/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.netcore.app/2.1.0/build/netcoreapp2.1/Microsoft.NETCore.App.targets" Condition="Exists('/usr/local/share/dotnet/sdk/NuGetFallbackFolder/microsoft.netcore.app/2.1.0/build/netcoreapp2.1/Microsoft.NETCore.App.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.fileproviders.embedded/2.1.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.fileproviders.embedded/2.1.0/build/netstandard2.0/Microsoft.Extensions.FileProviders.Embedded.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets/2.1.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets/2.1.0/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.extensions/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.extensions/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.Extensions.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.viewcompilation/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.mvc.razor.viewcompilation/2.1.0/build/netstandard2.0/Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)microsoft.aspnetcore.all/2.1.0/build/netcoreapp2.1/Microsoft.AspNetCore.All.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.aspnetcore.all/2.1.0/build/netcoreapp2.1/Microsoft.AspNetCore.All.targets')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
# API
|
||||
|
||||
Este projecto usa Dotnet Core 2 [.NET Core Guide](https://docs.microsoft.com/en-us/dotnet/core/)
|
||||
|
||||
## Executar servidor em modo watch (compiles on file change)
|
||||
|
||||
```
|
||||
dotnet watch run
|
||||
```
|
||||
|
||||
Executado servidor kestrel na porta 5000
|
||||
|
||||
|
||||
## Testar funcionalidades
|
||||
|
||||
Toda a API deve ser testada usando ferramentas como por exemplo [Postman](https://www.getpostman.com/)
|
||||
Toda a documentação das funcionalidades implementadas, assim como exemplos pode ser encontrada em [AQUI](https://documenter.getpostman.com/view/5070442/RWTsrFXi)
|
||||
|
Loading…
Reference in New Issue