Skip to content

Instantly share code, notes, and snippets.

Gonzalo Zamudio gzamudio

Block or report user

Report or block gzamudio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gzamudio
gzamudio / tasks.json
Created Oct 9, 2019
Tasks json file for .NET Core apps
View tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/{appPath}/{appName}.csproj",
@gzamudio
gzamudio / launch.json
Created Oct 9, 2019
VS Code launch file for .NET Core apps.
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/{appPath}/{appName}.dll",
"args": [],
View AccountApiController.cs
namespace NetCoreBootstrap.Api.V1.Controllers
{
[Route("/api/v1/[controller]/[action]")]
public class AccountApiController : Controller
{
...
[HttpPost("SignIn")]
public async Task<object> SignIn([FromBody] UserVO userValueObject)
{
View MetricApiController.cs
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[HttpGet("AllResourceCategoryMetric")]
public IActionResult ResourceCategoryMetric(string startingDate)
{
// TODO: roles not implemented yed, this metric is returns the same metric for any role
if (startingDate == string.Empty)
return BadRequest(Localizer["SelectATimePeriod"]);
var resources = UnitOfWork.ResourceRepository.GetAllWithRelatedEntitites().Where(ra =>
ra.UpdatedAt >= DateTime.ParseExact(startingDate, "dd/MM/yyyy", CultureInfo.InvariantCulture))
.ToList();
View MetricApiController.cs
private IEnumerable<Resource> GetSchoolGroupAccesedResources(int? schoolId, SchoolGroup schoolGroup, DateTime startingDate)
{
var schoolGroupResources = schoolGroup
.SchoolGroupPrograms
.SelectMany(sgp => sgp.EducationalProgram.EducationalProgramResources)
.Select(epr => epr.Resource)
.Where(r => r.UpdatedAt > startingDate);
IEnumerable<int> schoolUserIds = null;
if (schooId != null)
schoolUserIds = school.Teachers.Select(t => t.TeacherId).Concat(school.Managers.Select(m => m.ManagerId);
View MetricApiController.cs
public async Task<IActionResult> CategoryMetric(string startingDate, int? schoolId)
{
var currentUser = (await UserManager.FindByEmailAsync(User.Identity.Name));
try
{
if (GetSchoolToSearch(currentUser, schoolId) == null && !currentUser.IsInRole("Admin"))
return BadRequest(Localizer["UserIsNotSchoolGroupAdmin"]);
return Ok(GetSchoolGroupAccesedResources(schoolId,
currentUser.SchoolGroup, DateTime.ParseExact(startingDate,
"dd/MM/yyyy",
View CategoryRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using EduitorNetCore.Models.Database;
using EduitorNetCore.Models.VOs.Reduceds;
using EduitorNetCore.Repositories.Database;
using EduitorNetCore.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace EduitorNetCore.Repositories
View Repository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Project.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Project.Repositories
{
public class Repository<T> : IRepository<T> where T : class
View Repository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Project.Repositories.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace Project.Repositories
{
public class Repository<T> : IRepository<T> where T : class
View gist:91f92bb8e2c8ab761b030ffbe769c281
var keywords = new List<Tuple<int, string>>();
foreach(var obj in response)
{
var tuple = new Tuple<int, string>(Convert.ToInt32(obj), obj.ToString());
keywords.Add(tuple);
}
You can’t perform that action at this time.