Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #37 from skalahonza/opt
Browse files Browse the repository at this point in the history
Opt
  • Loading branch information
skalahonza authored Feb 23, 2018
2 parents 873e74a + 567b498 commit cb2323e
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 69 deletions.
4 changes: 0 additions & 4 deletions Chemiklani.BL/Chemiklani.BL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Identity.EntityFramework" Version="2.2.1" />
<PackageReference Include="Riganti.Utils.Infrastructure.Core" Version="2.0.0" />
<PackageReference Include="Riganti.Utils.Infrastructure.Services" Version="2.0.0" />
<PackageReference Include="Riganti.Utils.Infrastructure.AutoMapper" Version="2.0.0" />
<PackageReference Include="Riganti.Utils.Infrastructure.EntityFramework" Version="2.0.0" />
<PackageReference Include="EntityFramework" Version="6.1.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Chemiklani.BL/DTO/BaseDTO.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Riganti.Utils.Infrastructure.Core;
using Chemiklani.DAL.Entities;

namespace Chemiklani.BL.DTO
{
Expand Down
4 changes: 2 additions & 2 deletions Chemiklani.BL/DTO/IMappable.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Riganti.Utils.Infrastructure.Core;
using Chemiklani.DAL.Entities;

namespace Chemiklani.BL.DTO
{
public interface IMappable<TEntity>
public interface IMappable<in TEntity>
where TEntity:IEntity<int>
{
void MapFrom(TEntity entity);
Expand Down
45 changes: 23 additions & 22 deletions Chemiklani.BL/Services/ScoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public List<string> GetRooms()
/// <summary>
/// Get sore dataset for given list of teams
/// </summary>
/// <param name="room"></param>
/// <param name="room">Room, used for filter, elave empty if filter not required</param>
/// <param name="completeDataset">True: you can view points for each task</param>
/// <returns></returns>
public List<TeamScoreDTO> GetResults(string room = "", bool completeDataset = false)
Expand All @@ -118,6 +118,11 @@ public List<TeamScoreDTO> GetResults(string room = "", bool completeDataset = fa
})
.ToList();

var scores = dc.Scores
.Include(x => x.Task)
.Include(x => x.Team)
.ToList();

var competedTasks = dc.Tasks.ToList();

//get score for each team
Expand All @@ -129,7 +134,7 @@ public List<TeamScoreDTO> GetResults(string room = "", bool completeDataset = fa
{
Team = t,
TasksScores =
completeDataset ? new List<TaskScoreDTO>(TaskScores(t.Id, competedTasks).OrderBy(x => x.TaskNumber)) : new List<TaskScoreDTO>(),
completeDataset ? new List<TaskScoreDTO>(TaskScores(t.Id, competedTasks,scores).OrderBy(x => x.TaskNumber)) : new List<TaskScoreDTO>(),
TotalPoints = GetPointsOfTeam(t.Id),
});
});
Expand All @@ -151,33 +156,29 @@ public List<TeamScoreDTO> GetResults(string room = "", bool completeDataset = fa
/// </summary>
/// <param name="teamId">Team to be examined</param>
/// <param name="competedTasks">Tasks the team competed in</param>
/// <param name="allScores">All scores from database</param>
/// <returns></returns>
private List<TaskScoreDTO> TaskScores(int teamId, List<Task> competedTasks)
private List<TaskScoreDTO> TaskScores(int teamId, List<Task> competedTasks, List<Score> allScores)
{
using (var dc = CreateDbContext())
{
var result = new List<TaskScoreDTO>();
var result = new List<TaskScoreDTO>();

//get all tasks, team was evaluated in
var scores = dc.Scores
.Where(x => x.Team.Id == teamId)
.Include(x => x.Task);
//get all tasks, team was evaluated in
var scores = allScores.Where(x => x.Team.Id == teamId).ToList();

//add points where the team competed
foreach (var competedTask in competedTasks)
//add points where the team competed
foreach (var competedTask in competedTasks)
{
var score = scores.FirstOrDefault(x => x.Task.Id == competedTask.Id);
var dto = new TaskScoreDTO();
dto.MapFrom(competedTask);
if (score != null)
{
var score = scores.FirstOrDefault(x => x.Task.Id == competedTask.Id);
var dto = new TaskScoreDTO();
dto.MapFrom(competedTask);
if (score != null)
{
dto.Points = score.Points;
}
result.Add(dto);
dto.Points = score.Points;
}

return result;
result.Add(dto);
}

return result;
}

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions Chemiklani.BL/Services/TeamService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Chemiklani.BL.DTO;
Expand Down
1 change: 0 additions & 1 deletion Chemiklani.DAL/AppDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Data.Entity;
using Chemiklani.DAL.Entities;
using Microsoft.AspNet.Identity.EntityFramework;
Expand Down
7 changes: 1 addition & 6 deletions Chemiklani.DAL/Chemiklani.DAL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
<Reference Include="Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.1\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Riganti.Utils.Infrastructure.Core, Version=2.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Riganti.Utils.Infrastructure.Core.2.0.7\lib\net461\Riganti.Utils.Infrastructure.Core.dll</HintPath>
</Reference>
<Reference Include="Riganti.Utils.Infrastructure.EntityFramework, Version=2.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Riganti.Utils.Infrastructure.EntityFramework.2.0.7\lib\net461\Riganti.Utils.Infrastructure.EntityFramework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
Expand All @@ -65,6 +59,7 @@
<Compile Include="Entities\AppUserClaim.cs" />
<Compile Include="Entities\AppUserLogin.cs" />
<Compile Include="Entities\AppUserRole.cs" />
<Compile Include="Entities\IEntity.cs" />
<Compile Include="Entities\Score.cs" />
<Compile Include="Entities\Task.cs" />
<Compile Include="Entities\Team.cs" />
Expand Down
3 changes: 1 addition & 2 deletions Chemiklani.DAL/Entities/AppRole.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Chemiklani.DAL.Entities
{
Expand Down
4 changes: 1 addition & 3 deletions Chemiklani.DAL/Entities/AppUserClaim.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity.EntityFramework;
using Riganti.Utils.Infrastructure.Core;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Chemiklani.DAL.Entities
{
Expand Down
4 changes: 1 addition & 3 deletions Chemiklani.DAL/Entities/AppUserLogin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity.EntityFramework;
using Riganti.Utils.Infrastructure.Core;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Chemiklani.DAL.Entities
{
Expand Down
4 changes: 1 addition & 3 deletions Chemiklani.DAL/Entities/AppUserRole.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Identity.EntityFramework;
using Riganti.Utils.Infrastructure.Core;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Chemiklani.DAL.Entities
{
Expand Down
7 changes: 7 additions & 0 deletions Chemiklani.DAL/Entities/IEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Chemiklani.DAL.Entities
{
public interface IEntity<T>
{
T Id { get; set; }
}
}
2 changes: 0 additions & 2 deletions Chemiklani.DAL/Entities/Score.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Riganti.Utils.Infrastructure.Core;

namespace Chemiklani.DAL.Entities
{
public class Score : IEntity<int>
Expand Down
2 changes: 1 addition & 1 deletion Chemiklani.DAL/Entities/Task.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Riganti.Utils.Infrastructure.Core;


namespace Chemiklani.DAL.Entities
{
Expand Down
1 change: 0 additions & 1 deletion Chemiklani.DAL/Entities/Team.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Riganti.Utils.Infrastructure.Core;

namespace Chemiklani.DAL.Entities
{
Expand Down
1 change: 0 additions & 1 deletion Chemiklani.DAL/Migrations/201706011715579_Init.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Chemiklani.DAL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class Init : DbMigration
Expand Down
1 change: 0 additions & 1 deletion Chemiklani.DAL/Migrations/201707041218579_TeamsRooms.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Chemiklani.DAL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class TeamsRooms : DbMigration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Chemiklani.DAL.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class TeamCategories : DbMigration
Expand Down
7 changes: 3 additions & 4 deletions Chemiklani.DAL/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
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("iPodnik.DAL")]
[assembly: AssemblyTitle("Chemiklani")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("iPodnik.DAL")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyProduct("Chemiklani")]
[assembly: AssemblyCopyright("Copyright © Jan Skála 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 0 additions & 2 deletions Chemiklani.DAL/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net461" />
<package id="Riganti.Utils.Infrastructure.Core" version="2.0.7" targetFramework="net461" />
<package id="Riganti.Utils.Infrastructure.EntityFramework" version="2.0.7" targetFramework="net461" />
</packages>
8 changes: 4 additions & 4 deletions Chemiklani/Chemiklani.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="Riganti.Utils.Infrastructure.Core, Version=2.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Riganti.Utils.Infrastructure.Core.2.0.7\lib\net461\Riganti.Utils.Infrastructure.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
Expand Down Expand Up @@ -278,7 +275,9 @@
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="packages.config" />
<Content Include="packages.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Views\MasterPage.dotmaster" />
<Content Include="Controls\Menu.dotcontrol" />
<Content Include="Views\Default.dothtml" />
Expand All @@ -289,6 +288,7 @@
<Content Include="Views\Users.dothtml" />
<Content Include="Views\Score.dothtml" />
<Content Include="Views\Results.dothtml" />
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand Down
3 changes: 1 addition & 2 deletions Chemiklani/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand All @@ -10,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Chemiklani")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright © Jan Skála 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,24 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<UserName>$Chemiklani</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="DB" Order="1" Enabled="True">
<Destination Path="Data Source=tcp:chemiklanidbserver.database.windows.net,1433;Initial Catalog=Chemiklani_db;User ID=sqladmin@chemiklanidbserver;Password=Hesoyam12!" Name="Data Source=tcp:chemiklanidbserver.database.windows.net,1433;Initial Catalog=Chemiklani_db;User Id=sqladmin@chemiklanidbserver;Password=Hesoyam12!" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=(localdb)\mssqllocaldb;Initial Catalog=Chemiklani;Integrated Security=True" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\DB_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=(localdb)\mssqllocaldb; Integrated Security=true; Initial Catalog=Chemiklani" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="DB-Web.config Connection String">
<ParameterValue>Data Source=tcp:chemiklanidbserver.database.windows.net,1433;Initial Catalog=Chemiklani_db;User Id=sqladmin@chemiklanidbserver;Password=Hesoyam12!</ParameterValue>
</MSDeployParameterValue>
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions Chemiklani/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>bin\Release\PublishOutput</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion Chemiklani/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net451" />
<package id="Riganti.Utils.Infrastructure.Core" version="2.0.7" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
Expand Down

0 comments on commit cb2323e

Please sign in to comment.