Code Monkey home page Code Monkey logo

clinicahospitalar's Introduction

Repositório Oficial do Projeto MedicalManagement-Sys

Este projeto é o Caso de Uso do nosso Curso de Asp.NetCore MVC 2.2 - Do Zero ao Ninja

Tela ilustrativa inicial - Dashboard

Tela de Dashboard do MedicalManagenet-Sys

Interface de Repositório Genérico

  • Nossa Interface genérica, responsável pela assinatura do nosso Repositório Genérico;
  • Todos os métodos assinados aqui são genéricos e servem para a implementação com qualquer Estrutura de Dados;
  • Os parâmetros genéricos servem para que uma Entidade, que seja uma classe, seja recebida, assim como uma Chave;
  • A chave recebida é própria para que a Chave Primária seja do tipo genérico, escolhida pela equipe;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Cooperchip.ITDeveloper.Domain.Repository
{
    public interface IRepositoryGeneric<TEntity, TKey> : IDisposable
        where TEntity : class
    {
        //Task<List<TEntity>> SelecionarTodos(Expression<Func<TEntity, bool>> quando = null);
        IEnumerable<TEntity> SelecionarTodos(Expression<Func<TEntity, bool>> quando = null);
        TEntity SelecionarPorId(TKey id);

        void Inserir(TEntity obj);
        void Atualizar(TEntity obj);
        void Excluir(TEntity obj);
        void ExcluirPorId(TKey id);
    }
}
  • Nosso repositório genérico
using Cooperchip.ITDeveloper.Domain.Repository;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Cooperchip.ITDeveloper.Repository.Base
{
    public abstract class RepositoryGeneric<TEntity, TKey> : IRepositoryGeneric<TEntity, TKey>
        where TEntity : class, new()
    {
        protected DbContext Db;
        protected DbSet<TEntity> DbSet;

        protected RepositoryGeneric(DbContext ctx)
        {
            this.Db = ctx;
            this.DbSet = Db.Set<TEntity>();
        }

        public void Atualizar(TEntity obj)
        {
            Db.Entry(obj).State = EntityState.Modified;
            Salvar();
        }
        public void Excluir(TEntity obj)
        {
            Db.Entry(obj).State = EntityState.Deleted;
            Salvar();
        }
        public void ExcluirPorId(TKey id)
        {
            TEntity obj = SelecionarPorId(id);
            Excluir(obj);
        }
        public void Inserir(TEntity obj)
        {
            DbSet.Add(obj);
            Salvar();
        }
        public TEntity SelecionarPorId(TKey id)
        {
            return DbSet.Find(id);
        }
        public IEnumerable<TEntity> SelecionarTodos(Expression<Func<TEntity, bool>> expressaowhere = null)
        {
            if (expressaowhere == null)
            {
                return DbSet.AsNoTracking().ToList();
            }
            return DbSet.Where(expressaowhere).AsNoTracking().ToList();
        }
        public void Salvar()
        {
            Db.SaveChanges();
        }
        public void Dispose()
        {
            Db.Dispose();
        }
    }
}

Serviço de Aplicação: Em nossa Application Layer implementamos o Repositório genérico através do Domínio:

using Cooperchip.ITDeveloper.Application.Services.Interfaces;
using Cooperchip.ITDeveloper.Application.ViewModels;
using Cooperchip.ITDeveloper.Data.ORM;
using Cooperchip.ITDeveloper.Domain.Repository;
using System.Collections.Generic;
using Cooperchip.ITDeveloper.Domain.Models;

namespace Cooperchip.ITDeveloper.Application.Services
{
    public class ServiceApplicationPaciente : IServiceApplicationPaciente
    {
        private readonly IRepositoryDomainPaciente _repo;
        public ServiceApplicationPaciente(IRepositoryDomainPaciente repositoryRepoPaciente, ITDeveloperDbContext context)
        {
            this._repo = repositoryRepoPaciente;
        }
        public IEnumerable<PacienteViewModel> ListarPacientes()
        {
            var lista = _repo.SelecionarTodos();
            return RetornaPacienteViewModel(lista);
        }
        public IEnumerable<PacienteViewModel> ListarPacientesComEstado()
        {
            var lista = _repo.ListarPacientesComEstado();
            return RetornaPacienteViewModel(lista);
        }
        public List<PacienteViewModel> RetornaPacienteViewModel(IEnumerable<Paciente> lista)
        {
            List<PacienteViewModel> listaPaciente = new List<PacienteViewModel>();
            foreach (var item in lista)
            {
                PacienteViewModel paciente = new PacienteViewModel()
                {
                    Id = item.Id,
                    Nome = item.Nome,
                    Cpf = item.Cpf,
                    DataNascimento = item.DataNascimento,
                    DataInternacao = item.DataInternacao,
                    Email = item.Email,
                    Ativo = item.Ativo,
                    Rg = item.Rg,
                    RgDataEmissao = item.DataInternacao,
                    RgOrgao = item.RgOrgao,
                    Sexo = item.Sexo,
                    TipoPaciente = item.TipoPaciente,
                    EstadoPaciente = item.EstadoPaciente,
                    EstadoPacienteId = item.EstadoPacienteId
                };
                listaPaciente.Add(paciente);
            }
            return listaPaciente;

        }
    }
}

Tela ilustrativa de Mural de Avisos e Solicitações de Acesso

Tela de Mural do MedicalManagenet-Sys

DataCadastro:

Todo: O campo DataCadastro deve ser incluído automaticamente, mas não deve ser alterado. Este processo será implementado no contexto da aplicação.


TaskList - Tag Helpers

Feature Complexidade Status
Criar uma Tag Helper para exibir um e-mail no Rodapé Alta Ok
Podemos usar um domínio padrão ou um parametrizado Alta Ok
Vamos customizar a Tag Html "a", usando, inclusive, o mailTo Normal Not Implem
Preciso de uma classe com o sufixo Tagelper Baixa Not Implem
Preciso que a classe acima Herde de TagHelper Alta Not Implem
Package: using Microsoft.Asp.NetCore.Razor.TagHelpers Baixa Not Implem
Essa class precisa sobrescrever a Task ProcessAsync Média Not Implem
Parâmetros: (TagHelperContext context, TagHelperOutput output) Média Not Implem
Neste exemplo vamos deixar o context de lado Baixa Ok
Usaremos um domínio default ou receberemos no parâmetro Normal OK
Usaremos a notação Kebab Case: MeuEmail => meu-email Baixa Ok

Código pronto do nosso EmailTagHelper

using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.TagHelpers;

namespace Cooperchip.ITDeveloper.Mvc.Extentions.TagHelpers
{
    public class EmailTagHelper : TagHelper
    {
        public string Domain { get; set; } = "eaditdeveloper.com.br";
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "a";
            var content = await output.GetChildContentAsync();
            var target = content.GetContent() + "@" + Domain;
            output.Attributes.SetAttribute("href", "mailto:" + target);
            output.Content.SetContent(target);
        }
    }
}

Consultar a documentação para TagHelpers e ViewComponents, Leia aqui. Consultar a documentação para MarkDown, Leia aqui.

clinicahospitalar's People

Contributors

piscinao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.