Setup ef core tools and sqlite database with some entities

This commit is contained in:
Giovani
2019-04-20 00:39:07 +00:00
parent 3ed561ba0a
commit 382beefdc3
17 changed files with 424 additions and 9 deletions

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BrightGlimmer.Cqrs.Queries;
using MediatR;
using Microsoft.AspNetCore.Mvc;

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BrightGlimmer.Data.Repositories; /* REMOVE LATER */
using MediatR;
using Microsoft.AspNetCore.Mvc;
namespace BrightGlimmer.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class StudentController : ControllerBase
{
// private readonly IMediator mediator;
private readonly StudentRepository studentRepository;
public StudentController(StudentRepository studentRepository)
{
this.studentRepository = studentRepository;
}
[HttpGet]
public IActionResult GetAll()
{
var customers = studentRepository.GetAll();
if (customers == null)
{
return NotFound();
}
return new ObjectResult(customers);
}
[HttpGet("createstudent")]
public IActionResult CreateStudent()
{
var created = studentRepository.Create(new Data.Domain.Student
{
Id = Guid.NewGuid(),
FirstName = "Giovani",
LastName = "Rodriguez",
Email = "giovaniluisrodriguez@gmail.com",
Phones = new List<Data.Domain.Phone>
{
new Data.Domain.Phone
{
Id = Guid.NewGuid(),
AreaCode = 305,
Number = 8888888,
Type = Data.Domain.PhoneType.HOMEPHONE
}
}
});
return new ObjectResult(created);
}
}
}