{"id":21046308,"url":"https://github.com/alfredo1995/mvc","last_synced_at":"2025-05-15T18:31:16.923Z","repository":{"id":125101529,"uuid":"387313743","full_name":"alfredo1995/MVC","owner":"alfredo1995","description":"Web Application ASP.NET MVC 5 (.NET Framework) | Student registration system","archived":false,"fork":false,"pushed_at":"2024-05-14T09:01:34.000Z","size":46233,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-14T10:25:43.320Z","etag":null,"topics":["asp-net-mvc","dotnet","mvc","web-application"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=UxxNCY14xco\u0026t=55s","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alfredo1995.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-19T02:15:05.000Z","updated_at":"2024-05-14T09:01:38.000Z","dependencies_parsed_at":"2023-10-02T01:37:38.090Z","dependency_job_id":"e658c3db-7ffc-437c-8c99-60d491dd5e22","html_url":"https://github.com/alfredo1995/MVC","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredo1995%2FMVC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredo1995%2FMVC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredo1995%2FMVC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alfredo1995%2FMVC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alfredo1995","download_url":"https://codeload.github.com/alfredo1995/MVC/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225368287,"owners_count":17463366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net-mvc","dotnet","mvc","web-application"],"created_at":"2024-11-19T14:29:01.167Z","updated_at":"2024-11-19T14:29:01.972Z","avatar_url":"https://github.com/alfredo1995.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"MVC is used to create websites. In this case, controllers typically return a view (i.e., the HTML response) for browser requests.\n\nWeb APis, on the other hand, are made to be consumed by other applications. If you want to allow other applications to access your data/functionality, you can create a Web API to facilitate this access. For example, Facebook has an API to allow application developers to access information about users using the application.\n\nThe main difference between the project types is that the MVC project type adds web-specific things like standard CSS, JavaScript files and other resources required for a website, which are not required for an API.\n\n\u003cbr\u003e  \n  \ncrate new projetc \u003e criar uma Solução Vazia  \u003e Solution AppFuncional\n\n        Seleciona a Soluiton AppFuncional \u003e  criar um novo projeto \u003e ASP.NET Web Application (.NET Framework)\n  \n \nSetup of the new ASP.NET Web Application (.NET Framework) project within the AppFuncional solution\n\n        Nome AppMvc \u003edentro Repos \u003e dentro AppFuncional \u003e ASP.NET Web Application \u003e MVC \u003e CHANGE \u003e Individual user acounts\n \nSetting the migrations automatica\u003e   \n\n\tAppFuncional\u003eMigrations\u003e Configurations.cs \n\talterar AutomaticMigrationsEnabled de false para true;\n\t  public Configuration() \n        { \n            AutomaticMigrationsEnabled = true;\n        }   \n\nMaking database available / Enabling migrations\n\n        packge manager console\u003e enable-migrations            \n        packge manager console\u003e Update-Database -Verbose -force     \n        \nCreate Application Scafolding\n\n       AppFuncional\u003eAppMvc\u003eModels\u003e Criar class Aluno.cs\n       \nClass Aluno.cs\u003e\n\n       namespace AppMvc.Models\n\n       {\n       public class Aluno\n       {\n       } \n       } \n    \nAssign class properties Aluno.Cs \u003e                   \n              \n        using System;\n        using System.ComponentModel;\n        using System.ComponentModel.DataAnnotations;\n\n        namespace AppMvc.Models\n        {\n            public class Aluno \n            {\n                [Key]  \n                public int id { get; set; }\n            \n                [DisplayName(\"Nome Completo\")]\n                [Required(ErrorMessage =\"o campo {0} \")]\n                [MaxLength(100, ErrorMessage = \"no max 100 caracteres \")]\n                public string  Nome { get; set; }\n\n                [DisplayName(\"Email\")]\n                [Required(ErrorMessage = \"o campo {0} \")]\n                [MaxLength(100, ErrorMessage = \"O email e invalido \")]\n                public string Email { get; set; }\n\n                [Required(ErrorMessage = \"o campo {0} \")]\n                public string CPF { get; set; }\n\n                public DateTime DataMatricula { get; set; }\n                public bool Ativo { get; set; }\n\n            }\n        }\n\nCommand to compile the application to perform the next steps\n\n        crtl + shift + b \n\nCreate o Crud de Alunos \n       \n        AppFuncional\u003eAppMvc\u003eController\u003e Criar Controller\u003e Escolher MVC 5 Controller With Views, Using Entity Framework \u003e ADD \n        \n        Configurar a controller \u003e Model class : Aluno (AppMvc.Models) Data COntext class: ApplicationDbContext (AppMvc.Models) \n\n        Nome da controlle : AlunosController \u003e add \n        \nAdd o DbSet na  AppFuncional\u003eAppMVC\u003eModels\u003eIdentityModels.cs\n\n    using System.Data.Entity;\n\tusing System.Data.Entity.ModelConfiguration.Conventions;\n\tusing System.Security.Claims;\n\tusing System.Threading.Tasks;\n\tusing Microsoft.AspNet.Identity;\n\tusing Microsoft.AspNet.Identity.EntityFramework;\n\n\tnamespace AppMvc.Models\n\t{\n\t    // É possível adicionar dados do perfil do usuário adicionando mais propriedades na sua classe ApplicationUser\n\t    public class ApplicationUser : IdentityUser\n\t    {\n\t\tpublic async Task\u003cClaimsIdentity\u003e GenerateUserIdentityAsync(UserManager\u003cApplicationUser\u003e manager)\n\t\t{\n\t\t    // Observe que o authenticationType deve corresponder àquele definido em CookieAuthenticationOptions.AuthenticationType\n\t\t    var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);\n\t\t    // Adicionar declarações de usuário personalizado aqui\n\t\t    return userIdentity;\n\t\t}\n\t    }\n\n\t    public class ApplicationDbContext : IdentityDbContext\u003cApplicationUser\u003e\n\t    {\n\t\tpublic ApplicationDbContext()\n\t\t    : base(\"DefaultConnection\", throwIfV1Schema: false)\n\t\t{\n\t\t}\n\n\t\tpublic DbSet\u003cAluno\u003e Alunos { get; set; }\n\n\t\tpublic static ApplicationDbContext Create()\n\t\t{\n\t\t    return new ApplicationDbContext();\n\t\t}\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t    modelBuilder.Conventions.Remove\u003cPluralizingTableNameConvention\u003e();\n\t\t    modelBuilder.Entity\u003cAluno\u003e().ToTable(\"Alunos\");\n\t\t    base.OnModelCreating(modelBuilder);\n\t\t}\n\n\t\t    }\n\t}\n\n\nCommand to compile the application to perform the next steps\n\n        crtl + shift + b \n\n\nUpdates the database to the last migration or a specified migration\n\n        Packge manager Console\u003e Update-Database -Verbose \n\nConfigure route mapping by attributes\n\n        app.start \u003e RouteConfig.cs      =    routes.MapMvcAttributeRoutes();\n\n        Viwes\u003e Shared\u003e Layout.cs.html   =    \u003cli\u003e@Html.ActionLink(\"Alunos\", \"Index\", \"Alunos\")\u003c/li\u003e  \n\nMapeando as rotas e o verbos https\n\n        Controllers \u003e Alunos.Controller.cs \n\n        [HttpPost]                             =  Metodo de Requisição\n        [Route(\"Editar-Aluno/{id:int}\")]       =  Caminho da URL acessado pelo metodos\n\nImplementando as rotas e os metodos \n    \n        namespace AppMvc.Controllers{\n\n        public class AlunosController : Controller\n        {\n        private ApplicationDbContext db = new ApplicationDbContext();\n\n        [HttpGet]\n        [Route(\"Listar-Alunos\")]\n        public async Task\u003cActionResult\u003e Index()\n        {\n            return View(await db.Alunos.ToListAsync());\n        }\n\n        [HttpGet]\n        [Route(\"Listar-Detalhe/{id:int}\")]\n        public async Task\u003cActionResult\u003e Details(int id)\n        {            \n            Aluno aluno = await db.Alunos.FindAsync(id);\n            if (aluno == null)\n            {\n                return HttpNotFound();\n            }\n            return View(aluno);\n        }\n\n        [HttpGet]\n        [Route(\"Novo-Aluno\")]\n        public ActionResult Create()\n        {\n            return View();\n        }\n\n        [HttpPost]\n        [Route(\"Novo-Aluno\")]\n        [ValidateAntiForgeryToken]\n        public async Task\u003cActionResult\u003e Create([Bind(Include = \"id,Nome,Email,CPF,DataMatricula,Ativo\")] Aluno aluno)\n        {\n            if (ModelState.IsValid)\n            {\n                db.Alunos.Add(aluno);\n                await db.SaveChangesAsync();\n                return RedirectToAction(\"Index\");\n            }\n\n            return View(aluno);\n        }\n\n        [HttpGet]\n        [Route(\"Editar-Aluno/{id:int}\")]\n        public async Task\u003cActionResult\u003e Edit(int id)\n        {\n            Aluno aluno = await db.Alunos.FindAsync(id);\n            if (aluno == null)\n            {\n                return HttpNotFound();\n            }\n            return View(aluno);\n        }\n\n        [HttpPost]\n        [Route(\"Editar-Aluno/{id:int}\")]\n        [ValidateAntiForgeryToken]\n        public async Task\u003cActionResult\u003e Edit([Bind(Include = \"id,Nome,Email,CPF,DataMatricula,Ativo\")] Aluno aluno)\n        {\n            if (ModelState.IsValid)\n            {\n                db.Entry(aluno).State = EntityState.Modified;\n                await db.SaveChangesAsync();\n                return RedirectToAction(\"Index\");\n            }\n            return View(aluno);\n        }\n\n        [HttpGet]\n        [Route(\"Excluir-Aluno/{id:int}\")]\n        public async Task\u003cActionResult\u003e Delete(int id)\n        {\n            Aluno aluno = await db.Alunos.FindAsync(id);\n            if (aluno == null)\n            {\n                return HttpNotFound();\n            }\n            return View(aluno);\n        }\n\n        [HttpPost, ActionName(\"Delete\")]        \n        [ValidateAntiForgeryToken]\n        public async Task\u003cActionResult\u003e DeleteConfirmed(int id)\n        {\n            Aluno aluno = await db.Alunos.FindAsync(id);\n            db.Alunos.Remove(aluno);\n            await db.SaveChangesAsync();\n            return RedirectToAction(\"Index\");\n        }\n\n        protected override void Dispose(bool disposing)\n        {\n            if (disposing)\n            {\n                db.Dispose();\n            }\n            base.Dispose(disposing);\n        }  }   }\n        \n\nCustomizações visuais\n\n       Views \u003e Alunos \u003e Index.cshtml\n\nCustomizar Nome e o metodo de acesso da rota \u003e Index.cshtml\n\n       \u003ch2\u003eMatricula de Alunos\u003c/h2\u003e\n\n      \u003cp\u003e\n         \u003ca href=\"@Url.Action(\"Create\")\" class=\"btn btn-primary\"\u003eCadastro de Aluno\u003c/a\u003e\n      \u003c/p\u003e\n    \nCustomizar a tabela \u003e Index.cshtml\n\n       \u003ctd\u003e\n            \u003ca href=\"@Url.Action(\"Edit\", \"Alunos\", new { id = item.id })\" class=\"btn btn-primary\"\u003eEditar\u003c/a\u003e\n            \u003ca href=\"@Url.Action(\"Details\", \"Alunos\", new { id = item.id })\" class=\"btn btn-success\"\u003eDetalhe\u003c/a\u003e\n            \u003ca href=\"@Url.Action(\"Delete\", \"Alunos\", new { id = item.id })\" class=\"btn btn-danger\"\u003eExcluir\u003c/a\u003e\n      \u003c/td\u003e\n\t\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredo1995%2Fmvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falfredo1995%2Fmvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falfredo1995%2Fmvc/lists"}