From 19c67cfc60e981cf9f9456d28c908de910f7227f Mon Sep 17 00:00:00 2001 From: Kazeem Quadri <33027659+Darkace01@users.noreply.github.com> Date: Sun, 25 Oct 2020 17:25:28 +0100 Subject: [PATCH 1/3] Simplified the DTOs --- Dtos/CommandCreateDto.cs | 17 ----------------- Dtos/CommandDto.cs | 40 ++++++++++++++++++++++++++++++++++++++++ Dtos/CommandReadDto.cs | 12 ------------ Dtos/CommandUpdateDto.cs | 17 ----------------- 4 files changed, 40 insertions(+), 46 deletions(-) delete mode 100644 Dtos/CommandCreateDto.cs create mode 100644 Dtos/CommandDto.cs delete mode 100644 Dtos/CommandReadDto.cs delete mode 100644 Dtos/CommandUpdateDto.cs diff --git a/Dtos/CommandCreateDto.cs b/Dtos/CommandCreateDto.cs deleted file mode 100644 index 8d9ff57..0000000 --- a/Dtos/CommandCreateDto.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Commander.Dtos -{ - public class CommandCreateDto - { - [Required] - [MaxLength(250)] - public string HowTo { get; set; } - - [Required] - public string Line { get; set; } - - [Required] - public string Platform { get; set; } - } -} \ No newline at end of file diff --git a/Dtos/CommandDto.cs b/Dtos/CommandDto.cs new file mode 100644 index 0000000..37eda2c --- /dev/null +++ b/Dtos/CommandDto.cs @@ -0,0 +1,40 @@ +using System.ComponentModel.DataAnnotations; + +namespace Commander.Dtos +{ + public class CommandCreateDto + { + [Required] + [MaxLength(250)] + public string HowTo { get; set; } + + [Required] + public string Line { get; set; } + + [Required] + public string Platform { get; set; } + } + + public class CommandReadDto + { + public int Id { get; set; } + + public string HowTo { get; set; } + + public string Line { get; set; } + + } + + public class CommandUpdateDto + { + [Required] + [MaxLength(250)] + public string HowTo { get; set; } + + [Required] + public string Line { get; set; } + + [Required] + public string Platform { get; set; } + } +} \ No newline at end of file diff --git a/Dtos/CommandReadDto.cs b/Dtos/CommandReadDto.cs deleted file mode 100644 index 34c8a14..0000000 --- a/Dtos/CommandReadDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Commander.Dtos -{ - public class CommandReadDto - { - public int Id { get; set; } - - public string HowTo { get; set; } - - public string Line { get; set; } - - } -} \ No newline at end of file diff --git a/Dtos/CommandUpdateDto.cs b/Dtos/CommandUpdateDto.cs deleted file mode 100644 index 9e7154a..0000000 --- a/Dtos/CommandUpdateDto.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Commander.Dtos -{ - public class CommandUpdateDto - { - [Required] - [MaxLength(250)] - public string HowTo { get; set; } - - [Required] - public string Line { get; set; } - - [Required] - public string Platform { get; set; } - } -} \ No newline at end of file From 77c906ec99ea28c3609b5879aefe8da6f4a6a36c Mon Sep 17 00:00:00 2001 From: Kazeem Quadri <33027659+Darkace01@users.noreply.github.com> Date: Sun, 25 Oct 2020 17:30:42 +0100 Subject: [PATCH 2/3] Simplified Code and Repository --- .gitignore | 434 ++++++++++++++++++ Controllers/CommandsController.cs | 31 +- Data/SqlCommanderRepo.cs | 4 +- .../netcoreapp3.1/Commander.assets.cache | Bin 39615 -> 48 bytes 4 files changed, 449 insertions(+), 20 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ef47fb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,434 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +obj/Debug/netcoreapp3.1/Commander.assets.cache diff --git a/Controllers/CommandsController.cs b/Controllers/CommandsController.cs index f56695e..7025b64 100644 --- a/Controllers/CommandsController.cs +++ b/Controllers/CommandsController.cs @@ -22,10 +22,10 @@ public CommandsController(ICommanderRepo repository, IMapper mapper) _repository = repository; _mapper = mapper; } - + //GET api/commands [HttpGet] - public ActionResult > GetAllCommmands() + public ActionResult> GetAllCommmands() { var commandItems = _repository.GetAllCommands(); @@ -33,11 +33,11 @@ public CommandsController(ICommanderRepo repository, IMapper mapper) } //GET api/commands/{id} - [HttpGet("{id}", Name="GetCommandById")] - public ActionResult GetCommandById(int id) + [HttpGet("{id}", Name = "GetCommandById")] + public ActionResult GetCommandById(int id) { var commandItem = _repository.GetCommandById(id); - if(commandItem != null) + if (commandItem != null) { return Ok(_mapper.Map(commandItem)); } @@ -46,15 +46,14 @@ public CommandsController(ICommanderRepo repository, IMapper mapper) //POST api/commands [HttpPost] - public ActionResult CreateCommand(CommandCreateDto commandCreateDto) + public ActionResult CreateCommand(CommandCreateDto commandCreateDto) { var commandModel = _mapper.Map(commandCreateDto); _repository.CreateCommand(commandModel); - _repository.SaveChanges(); var commandReadDto = _mapper.Map(commandModel); - return CreatedAtRoute(nameof(GetCommandById), new {Id = commandReadDto.Id}, commandReadDto); + return CreatedAtRoute(nameof(GetCommandById), new { Id = commandReadDto.Id }, commandReadDto); } //PUT api/commands/{id} @@ -62,16 +61,13 @@ public CommandsController(ICommanderRepo repository, IMapper mapper) public ActionResult UpdateCommand(int id, CommandUpdateDto commandUpdateDto) { var commandModelFromRepo = _repository.GetCommandById(id); - if(commandModelFromRepo == null) + if (commandModelFromRepo == null) { return NotFound(); } _mapper.Map(commandUpdateDto, commandModelFromRepo); _repository.UpdateCommand(commandModelFromRepo); - - _repository.SaveChanges(); - return NoContent(); } @@ -80,7 +76,7 @@ public ActionResult UpdateCommand(int id, CommandUpdateDto commandUpdateDto) public ActionResult PartialCommandUpdate(int id, JsonPatchDocument patchDoc) { var commandModelFromRepo = _repository.GetCommandById(id); - if(commandModelFromRepo == null) + if (commandModelFromRepo == null) { return NotFound(); } @@ -88,7 +84,7 @@ public ActionResult PartialCommandUpdate(int id, JsonPatchDocument(commandModelFromRepo); patchDoc.ApplyTo(commandToPatch, ModelState); - if(!TryValidateModel(commandToPatch)) + if (!TryValidateModel(commandToPatch)) { return ValidationProblem(ModelState); } @@ -97,8 +93,6 @@ public ActionResult PartialCommandUpdate(int id, JsonPatchDocument GetAllCommands() @@ -50,7 +52,7 @@ public bool SaveChanges() public void UpdateCommand(Command cmd) { - //Nothing + SaveChanges(); } } } \ No newline at end of file diff --git a/obj/Debug/netcoreapp3.1/Commander.assets.cache b/obj/Debug/netcoreapp3.1/Commander.assets.cache index a5f514d8050eae40afb838b758c3843fe058e7a6..210df19870a6b302d824eeab4f189df7aea09376 100644 GIT binary patch literal 48 zcmZQzU})fCU|^UlCFv0Af66ZWFAvY5N`>DG_#T$s`SAIRWqobyvY*C|KqUC3 B5sm-= literal 39615 zcmdU22bfjIbw-wujAWsXx&#PGNWfjXK$c{d1*DY$VHR0-vX1xh_Od+j%KE*x6uGy= za*fmDBu;S>CvmD1$98(}#c_J?-RaGV)BgY7IWyG?+URAVk4Om|w%es9n_F^uBwur)k) zqTlGmXL|ip&0ar_8r??w+*1s_E!q-on|9B$ytLzmO03yBqFB6+jyc!(OK`KOgs}cSoC}&C~7H@o7L93>)3qM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y3tE(~ppQRkeB zz7(7dtm&)3rPy3qt9;jim+%2cY@6ZCj%817>8YQw^vuqfIkR(d`e+r&BUSVcj@)E3 zGN-Y^N*4XeNL!5(pg4%*!L$ad|NX-3hpmVH7k*m_j=R}=xeQyWRJ86Xld!Y+%%Rgxn6*a?dj*)F}1 z)aaT}Z5*K{RTF7x%VHd|Lzh3q@sOpUhlBu!d{Abz4PKSe;o!Ej3w1^+11myTWL-G4 z^fm>9VSfE3ciRF{b;|ksi(q*n1ynYq&JGt+ zs(b*HZS(~p_te8=r|+4?BCCmwpdbN%os^5`J5XzTMHad+*MJIVxGrIj2 zoo+-f>!r|abh)JyGs(tMQLD;hv0a~TQlmn#k?8z!k>s)`$mbTnR1@Il_`rBD%cKZY z)3B?8MqBXIdF07@38HU Date: Sun, 25 Oct 2020 17:32:21 +0100 Subject: [PATCH 3/3] Simplified IF Statements --- Controllers/CommandsController.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Controllers/CommandsController.cs b/Controllers/CommandsController.cs index 7025b64..dd0b4a3 100644 --- a/Controllers/CommandsController.cs +++ b/Controllers/CommandsController.cs @@ -38,9 +38,7 @@ public ActionResult GetCommandById(int id) { var commandItem = _repository.GetCommandById(id); if (commandItem != null) - { return Ok(_mapper.Map(commandItem)); - } return NotFound(); } @@ -62,9 +60,7 @@ public ActionResult UpdateCommand(int id, CommandUpdateDto commandUpdateDto) { var commandModelFromRepo = _repository.GetCommandById(id); if (commandModelFromRepo == null) - { return NotFound(); - } _mapper.Map(commandUpdateDto, commandModelFromRepo); _repository.UpdateCommand(commandModelFromRepo); @@ -77,17 +73,12 @@ public ActionResult PartialCommandUpdate(int id, JsonPatchDocument(commandModelFromRepo); patchDoc.ApplyTo(commandToPatch, ModelState); if (!TryValidateModel(commandToPatch)) - { return ValidationProblem(ModelState); - } _mapper.Map(commandToPatch, commandModelFromRepo); @@ -102,9 +93,7 @@ public ActionResult DeleteCommand(int id) { var commandModelFromRepo = _repository.GetCommandById(id); if (commandModelFromRepo == null) - { return NotFound(); - } _repository.DeleteCommand(commandModelFromRepo); return NoContent();