Commit df8b7ae3 authored by  Bruno Daniel Di Bello Baladan's avatar Bruno Daniel Di Bello Baladan
Browse files

Capa de presentacion terminada. Refreshee el modelo porque agregue un stored...

Capa de presentacion terminada. Refreshee el modelo porque agregue un stored procedure (ojo si les da error).
parent 4d8df6f4
Pipeline #199 skipped
......@@ -31,7 +31,7 @@ namespace BusinessLogicLayer
public void DeleteEmployee(int id)
{
throw new NotImplementedException();
_dal.DeleteEmployee(id);
}
public void UpdateEmployee(Employee emp)
......
......@@ -5,7 +5,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="tsi_pr1Entities" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ts1sb.database.windows.net;initial catalog=tsi_pr1;persist security info=True;user id=tsiroot;password=Passw0rd.;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
<add name="tsi_pr1Entities" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ts1sb.database.windows.net;initial catalog=tsi_pr1;persist security info=True;user id=tsiroot;password=Passw0rd.;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
......@@ -13,4 +13,4 @@
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
\ No newline at end of file
</configuration>
\ No newline at end of file
......@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataAccessLayer
{
public class DALEmployeesEF : IDALEmployees
......@@ -37,7 +38,6 @@ namespace DataAccessLayer
{
using (var context = new Model.tsi_pr1Entities())
{
var result = from emp in context.Employees
where emp.Id == id
select emp;
......@@ -56,39 +56,26 @@ namespace DataAccessLayer
//throw new NotImplementedException();
}
//Bruno
public void UpdateEmployee(Employee emp)
{
using (var context = new Model.tsi_pr1Entities())
{
var result = from e in context.Employees
where e.Id == emp.Id
select e;
if (result.Count()==1)
if (emp is FullTimeEmployee)
{
context.UpdateEmployee(emp.Id, emp.Name, emp.StartDate, ((FullTimeEmployee)emp).Salary, null, 1);
}
else
{
Model.Employee original = result.First();
if (original != null)
{
if (emp is FullTimeEmployee)
{
((Model.FullTimeEmployee)original).Salary = ((FullTimeEmployee)emp).Salary;
}
else
{
((Model.PartTimeEmployee)original).HourlyRate = ((PartTimeEmployee)emp).HourlyRate;
}
original.Name = emp.Name;
original.StartDate = emp.StartDate;
context.SaveChanges();
}
}
context.UpdateEmployee(emp.Id, emp.Name, emp.StartDate, null, (int)((PartTimeEmployee)emp).HourlyRate, 0);
}
context.SaveChanges();
}
}
public List<Employee> GetAllEmployees()
{
List<Employee> employees = new List<Employee>();
using (var context = new Model.tsi_pr1Entities())
{
......@@ -127,13 +114,13 @@ namespace DataAccessLayer
if (employee is Model.FullTimeEmployee)
{
Shared.Entities.FullTimeEmployee tmp = new Shared.Entities.FullTimeEmployee();
tmp.Salary = ((Model.FullTimeEmployee)employee).Salary;
tmp.Salary = (int)((Model.FullTimeEmployee)employee).Salary;
result = tmp;
}
else
{
Shared.Entities.PartTimeEmployee tmp = new Shared.Entities.PartTimeEmployee();
tmp.HourlyRate = ((Model.PartTimeEmployee)employee).HourlyRate;
tmp.HourlyRate = (double)((Model.PartTimeEmployee)employee).HourlyRate;
result = tmp;
}
......
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
using System.Collections.Generic;
public abstract partial class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public System.DateTime StartDate { get; set; }
}
}
public abstract partial class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public System.DateTime StartDate { get; set; }
}
}
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
using System.Collections.Generic;
public partial class FullTimeEmployee : Employee
{
public int Salary { get; set; }
}
}
public partial class FullTimeEmployee : Employee
{
public Nullable<int> Salary { get; set; }
}
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
......@@ -9,34 +7,56 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataAccessLayer.Model
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class tsi_pr1Entities : DbContext
{
public tsi_pr1Entities()
: base("name=tsi_pr1Entities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Core.Objects;
using System.Linq;
public partial class tsi_pr1Entities : DbContext
{
throw new UnintentionalCodeFirstException();
public tsi_pr1Entities()
: base("name=tsi_pr1Entities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<database_firewall_rules> database_firewall_rules { get; set; }
public virtual int UpdateEmployee(Nullable<int> iD, string name, Nullable<System.DateTime> startDate, Nullable<int> salary, Nullable<int> rate, Nullable<int> type)
{
var iDParameter = iD.HasValue ?
new ObjectParameter("ID", iD) :
new ObjectParameter("ID", typeof(int));
var nameParameter = name != null ?
new ObjectParameter("Name", name) :
new ObjectParameter("Name", typeof(string));
var startDateParameter = startDate.HasValue ?
new ObjectParameter("StartDate", startDate) :
new ObjectParameter("StartDate", typeof(System.DateTime));
var salaryParameter = salary.HasValue ?
new ObjectParameter("Salary", salary) :
new ObjectParameter("Salary", typeof(int));
var rateParameter = rate.HasValue ?
new ObjectParameter("Rate", rate) :
new ObjectParameter("Rate", typeof(int));
var typeParameter = type.HasValue ?
new ObjectParameter("Type", type) :
new ObjectParameter("Type", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("UpdateEmployee", iDParameter, nameParameter, startDateParameter, salaryParameter, rateParameter, typeParameter);
}
}
public virtual DbSet<Employee> Employees { get; set; }
public virtual DbSet<database_firewall_rules> database_firewall_rules { get; set; }
}
}
// T4 code generation is enabled for model 'D:\Facultad\TSI1\GIT\Practico1\DataAccessLayer\Model\Model.edmx'.
// T4 code generation is enabled for model 'C:\Users\Bruno\Documents\Practico1\DataAccessLayer\Model\Model.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.
......

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
......@@ -9,4 +7,3 @@
// </auto-generated>
//------------------------------------------------------------------------------
......@@ -4,7 +4,7 @@
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="tsi_pr1Model.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">
<Schema Namespace="tsi_pr1Model.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="EmployeesTPH">
<Key>
<PropertyRef Name="ID" />
......@@ -34,6 +34,14 @@ warning 6002: The table/view 'tsi_pr1.sys.database_firewall_rules' does not have
<Property Name="create_date" Type="datetime" Nullable="false" />
<Property Name="modify_date" Type="datetime" Nullable="false" />
</EntityType>
<Function Name="UpdateEmployee" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
<Parameter Name="ID" Type="int" Mode="In" />
<Parameter Name="Name" Type="nvarchar" Mode="In" />
<Parameter Name="StartDate" Type="datetime" Mode="In" />
<Parameter Name="Salary" Type="int" Mode="In" />
<Parameter Name="Rate" Type="int" Mode="In" />
<Parameter Name="Type" Type="int" Mode="In" />
</Function>
<EntityContainer Name="tsi_pr1ModelStoreContainer">
<EntitySet Name="EmployeesTPH" EntityType="Self.EmployeesTPH" Schema="dbo" store:Type="Tables" />
<EntitySet Name="database_firewall_rules" EntityType="Self.database_firewall_rules" store:Type="Views" store:Schema="sys">
......@@ -47,8 +55,7 @@ warning 6002: The table/view 'tsi_pr1.sys.database_firewall_rules' does not have
FROM [sys].[database_firewall_rules] AS [database_firewall_rules]</DefiningQuery>
</EntitySet>
</EntityContainer>
</Schema>
</edmx:StorageModels>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="tsi_pr1Model" 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">
......@@ -79,12 +86,20 @@ warning 6002: The table/view 'tsi_pr1.sys.database_firewall_rules' does not have
<EntityContainer Name="tsi_pr1Entities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="Employees" EntityType="tsi_pr1Model.Employee" />
<EntitySet Name="database_firewall_rules" EntityType="Self.database_firewall_rules" />
<FunctionImport Name="UpdateEmployee">
<Parameter Name="ID" Mode="In" Type="Int32" />
<Parameter Name="Name" Mode="In" Type="String" />
<Parameter Name="StartDate" Mode="In" Type="DateTime" />
<Parameter Name="Salary" Mode="In" Type="Int32" />
<Parameter Name="Rate" Mode="In" Type="Int32" />
<Parameter Name="Type" Mode="In" Type="Int32" />
</FunctionImport>
</EntityContainer>
<EntityType Name="PartTimeEmployee" BaseType="tsi_pr1Model.Employee" >
<Property Name="HourlyRate" Type="Double" Nullable="false" />
<Property Name="HourlyRate" Type="Double" />
</EntityType>
<EntityType Name="FullTimeEmployee" BaseType="tsi_pr1Model.Employee" >
<Property Name="Salary" Type="Int32" Nullable="false" />
<Property Name="Salary" Type="Int32" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
......@@ -127,6 +142,7 @@ warning 6002: The table/view 'tsi_pr1.sys.database_firewall_rules' does not have
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<FunctionImportMapping FunctionImportName="UpdateEmployee" FunctionName="tsi_pr1Model.Store.UpdateEmployee" />
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
......
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
using System.Collections.Generic;
public partial class PartTimeEmployee : Employee
{
public double HourlyRate { get; set; }
}
}
public partial class PartTimeEmployee : Employee
{
public Nullable<double> HourlyRate { get; set; }
}
}
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
//------------------------------------------------------------------------------
// <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 DataAccessLayer.Model
{
using System;
using System.Collections.Generic;
public partial class database_firewall_rules
{
public int id { get; set; }
public string name { get; set; }
public string start_ip_address { get; set; }
public string end_ip_address { get; set; }
public System.DateTime create_date { get; set; }
public System.DateTime modify_date { get; set; }
}
}
public partial class database_firewall_rules
{
public int id { get; set; }
public string name { get; set; }
public string start_ip_address { get; set; }
public string end_ip_address { get; set; }
public System.DateTime create_date { get; set; }
public System.DateTime modify_date { get; set; }
}
}
......@@ -5,7 +5,7 @@
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="tsi_pr1Entities" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ts1sb.database.windows.net;initial catalog=tsi_pr1;persist security info=True;user id=tsiroot;password=Passw0rd.;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
<add name="tsi_pr1Entities" connectionString="metadata=res://*/Model.Model.csdl|res://*/Model.Model.ssdl|res://*/Model.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ts1sb.database.windows.net;initial catalog=tsi_pr1;persist security info=True;user id=tsiroot;password=Passw0rd.;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
......@@ -13,4 +13,4 @@
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
\ No newline at end of file
</configuration>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment