Commit 392cf0e5 authored by Ben Tecu's avatar Ben Tecu

Initial commit

parent d0ac0ce2
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseIISExpress>true</UseIISExpress>
<Use64BitIISExpress />
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
<Controller_SelectedScaffolderID>ApiControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Controller</Controller_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<NameOfLastUsedPublishProfile>AgendaExampleAPI - Web Deploy</NameOfLastUsedPublishProfile>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>True</EnableENC>
<AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace Agenda_Example_API
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.Formatters.Remove(config.Formatters.XmlFormatter);
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
using Agenda_Example_API.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace Agenda_Example_API.Controllers
{
public class ContactsController : ApiController
{
ContactModel model;
public ContactsController()
{
this.model = new ContactModel();
}
// GET: api/Contacts
public List<Contact> Get()
{
return model.GetContacts();
}
// GET: api/Contacts/5
public Contact Get(int id)
{
return model.GetContactByID(id);
}
// POST: api/Contacts
public void Post(Contact c)
{
this.model.AddContact(c);
}
// PUT: api/Contacts/5
public void Put(Contact c)
{
this.model.EditContact(c);
}
// DELETE: api/Contacts/5
public void Delete(int id)
{
this.model.DeleteContact(id);
}
}
}
<%@ Application Codebehind="Global.asax.cs" Inherits="Agenda_Example_API.WebApiApplication" Language="C#" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Routing;
namespace Agenda_Example_API
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Agenda_Example_API.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class AgendaContext : DbContext
{
public AgendaContext()
: base("name=AgendaContext")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Contact> Contact { get; set; }
}
}
This diff is collapsed.
// T4 code generation is enabled for model 'C:\Users\MCSD2017\Documents\Visual Studio 2017\Projects\Agenda Example WebAPI MVC Solution\Agenda Example API\Models\AgendaContext.edmx'.
// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
// is open in the designer.
// If no context and entity classes have been generated, it may be because you created an empty model but
// have not yet chosen which version of Entity Framework to use. To generate a context class and entity
// classes for your model, open the model in the designer, right-click on the designer surface, and
// select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
// Item...'.
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="AGENDAModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012.Azure" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityType Name="Contact">
<Key>
<PropertyRef Name="ContactId" />
</Key>
<Property Name="ContactId" Type="int" Nullable="false" />
<Property Name="Nombre" Type="nvarchar" MaxLength="50" />
<Property Name="Apellidos" Type="nvarchar" MaxLength="50" />
<Property Name="Fecha_Nacimiento" Type="datetime" />
<Property Name="Email" Type="nvarchar" MaxLength="50" />
<Property Name="Telefono" Type="nvarchar" MaxLength="50" />
</EntityType>
<EntityContainer Name="AGENDAModelStoreContainer">
<EntitySet Name="Contact" EntityType="Self.Contact" Schema="dbo" store:Type="Tables" />
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="AGENDAModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="AgendaContext" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Contact" EntityType="AGENDAModel.Contact" />
</EntityContainer>
<EntityType Name="Contact">
<Key>
<PropertyRef Name="ContactId" />
</Key>
<Property Name="ContactId" Type="Int32" Nullable="false" />
<Property Name="Nombre" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Apellidos" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Fecha_Nacimiento" Type="DateTime" Precision="3" />
<Property Name="Email" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Telefono" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="AGENDAModelStoreContainer" CdmEntityContainer="AgendaContext">
<EntitySetMapping Name="Contact">
<EntityTypeMapping TypeName="AGENDAModel.Contact">
<MappingFragment StoreEntitySet="Contact">
<ScalarProperty Name="Telefono" ColumnName="Telefono" />
<ScalarProperty Name="Email" ColumnName="Email" />
<ScalarProperty Name="Fecha_Nacimiento" ColumnName="Fecha_Nacimiento" />
<ScalarProperty Name="Apellidos" ColumnName="Apellidos" />
<ScalarProperty Name="Nombre" ColumnName="Nombre" />
<ScalarProperty Name="ContactId" ColumnName="ContactId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="false" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
<DesignerProperty Name="UseLegacyProvider" Value="false" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram DiagramId="e9bbcbb9528d4c7ebb459b70e4d16602" Name="Diagram1">
<EntityTypeShape EntityType="AGENDAModel.Contact" Width="1.5" PointX="3.375" PointY="0.75" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>
\ No newline at end of file
This diff is collapsed.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Agenda_Example_API.Models
{
using System;
using System.Collections.Generic;
public partial class Contact
{
public int ContactId { get; set; }
public string Nombre { get; set; }
public string Apellidos { get; set; }
public Nullable<System.DateTime> Fecha_Nacimiento { get; set; }
public string Email { get; set; }
public string Telefono { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Agenda_Example_API.Models
{
public class ContactModel
{
AgendaContext ctx;
public ContactModel()
{
this.ctx = new AgendaContext();
}
//GET api/Contacts
public List<Contact> GetContacts()
{
var query = from data in ctx.Contact select data;
return query.ToList();
}
//GET api/Contacts/{id}
public Contact GetContactByID(int cID)
{
Contact c = ctx.Contact.Find(cID);
return c;
}
//METODO POST
public void AddContact(Contact c)
{
int lastID = ctx.Contact.OrderByDescending(z => z.ContactId).FirstOrDefault().ContactId;
c.ContactId = lastID + 1;
this.ctx.Contact.Add(c);
this.ctx.SaveChanges();
}
//METODO PUT
public void EditContact(Contact c)
{
Contact contact = this.GetContactByID(c.ContactId);
contact.Nombre = c.Nombre;
contact.Apellidos = c.Apellidos;
contact.Email = c.Email;
contact.Telefono = c.Telefono;
this.ctx.SaveChanges();
}
//METODO DELETE
public void DeleteContact(int cID)
{
Contact c = this.GetContactByID(cID);
this.ctx.Contact.Remove(c);
this.ctx.SaveChanges();
}
}
}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Agenda_Example_API")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Agenda_Example_API")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("34b05c00-9d8b-45aa-af2c-06bb4ed8c923")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<ResourceId>/subscriptions/c9a09bbf-9133-455a-9e0a-3b552c18e7b1/resourcegroups/RecursosTajamar/providers/Microsoft.Web/sites/AgendaExampleAPI</ResourceId>
<ResourceGroup>RecursosTajamar</ResourceGroup>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://agendaexampleapi.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>agendaexampleapi.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>AgendaExampleAPI</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$AgendaExampleAPI</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAkudTKT+OQUygjNlibPDTnwAAAAACAAAAAAAQZgAAAAEAACAAAAB2M1sJX9IJZkapL09qJCF/5m8G4fOFZLO9r8L0BT2qTQAAAAAOgAAAAAIAACAAAAA9AIvBbvxavXszHnGxy/2M35u6u18JO2FP7ewY2yMQKIAAAABiw7lFENK0ZFqRg+TPlyiWUbyQvwgbn+9i9rv257vQ/BpTTg3O/7BIZZV8jBRX1Ua1/93sBuTrzdQ7Sk2UCcPnkvxLGwuu5646xoA8RDVd9zXxKMJepU57/EbTkeQ4f90p41Lsnt6KKJSMBBnOjVl4HmdYO555atQjufNJRrv8/EAAAABjG9PdwCrds420V+D856hbfZuDi8Z5/nxc7savy51vxp3lKA85wDLUAsY+j6Cp/cGuUn21/kVadYHquS49d0sS</EncryptedPassword>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=301879
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings></appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />