develop #1
@ -9,10 +9,10 @@ namespace Posechaemost.Data.Repository
|
|||||||
{
|
{
|
||||||
public interface IPresenceRepository
|
public interface IPresenceRepository
|
||||||
{
|
{
|
||||||
List<PresenceLocalEntity> GetPresenceListByGroup(int groupId);
|
List<PresenceLocalEntity> GetPresenceByGroup(int groupId);
|
||||||
List<PresenceLocalEntity> GetPresenceListByGroupAndDate(int groupId, DateOnly date);
|
List<PresenceLocalEntity> GetPresenceByGroupAndDate(int groupId, DateOnly date);
|
||||||
|
bool UncheckAttendence(PresenceLocalEntity presence);
|
||||||
void UncheckAttendence(Presence presence);
|
void AddPresence(PresenceLocalEntity presence);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,19 +16,37 @@ namespace Posechaemost.Data.Repository
|
|||||||
public List<PresenceLocalEntity> GetAllPresences
|
public List<PresenceLocalEntity> GetAllPresences
|
||||||
{ get; set; }
|
{ get; set; }
|
||||||
|
|
||||||
public List<PresenceLocalEntity> GetPresenceListByGroup(int groupId)
|
public void AddPresence(PresenceLocalEntity presence)
|
||||||
|
{
|
||||||
|
PresenceLocalEntity? presenceLocal = GetAllPresences.FirstOrDefault();
|
||||||
|
// GroupLocalEntity? group = new GroupLocalEntity();
|
||||||
|
presenceLocal.ClassNumber = presence.ClassNumber;
|
||||||
|
presence.UserGuid = presence.UserGuid;
|
||||||
|
presenceLocal.Date = presence.Date;
|
||||||
|
presenceLocal.IsAttendence = presence.IsAttendence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PresenceLocalEntity> GetPresenceByGroup(int groupId)
|
||||||
{
|
{
|
||||||
return GetAllPresences;
|
return GetAllPresences;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PresenceLocalEntity> GetPresenceListByGroupAndDate(int groupId, DateOnly date)
|
public List<PresenceLocalEntity> GetPresenceByGroupAndDate(int groupId, DateOnly date)
|
||||||
{
|
{
|
||||||
return GetAllPresences;
|
return GetAllPresences;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UncheckAttendence(Presence presence)
|
public bool UncheckAttendence(PresenceLocalEntity presence)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var presToUpdate = GetAllPresences
|
||||||
|
.Where(x => x.IsAttendence == presence.IsAttendence
|
||||||
|
&& x.UserGuid == presence.UserGuid && x.Date == presence.Date
|
||||||
|
&& x.ClassNumber == presence.ClassNumber).ToList();
|
||||||
|
|
||||||
|
foreach (var pres in presToUpdate) {
|
||||||
|
presence.IsAttendence = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
71
Domain/UseCase/PresenceUseCase.cs
Normal file
71
Domain/UseCase/PresenceUseCase.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Posechaemost.Data.LocalData.Entity;
|
||||||
|
using Posechaemost.Data.Repository;
|
||||||
|
using Posechaemost.Domain.Models;
|
||||||
|
|
||||||
|
namespace Posechaemost.Domain.UseCase
|
||||||
|
{
|
||||||
|
public class PresenceUseCase
|
||||||
|
{
|
||||||
|
private readonly PresenceRepositoryImpl _repositoryPresenceImpl;
|
||||||
|
private readonly UserRepositoryImpl _repositoryUserImpl;
|
||||||
|
private readonly GroupRepositoryImpl _repositoryGroupImpl;
|
||||||
|
|
||||||
|
public PresenceUseCase(PresenceRepositoryImpl repositoryImpl, UserRepositoryImpl userRepositoryImpl, GroupRepositoryImpl groupRepositoryImpl) {
|
||||||
|
_repositoryPresenceImpl = repositoryImpl;
|
||||||
|
_repositoryUserImpl = userRepositoryImpl;
|
||||||
|
_repositoryGroupImpl = groupRepositoryImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Presence> GetPresenceByGroup(int groupId) {
|
||||||
|
var users = _repositoryUserImpl.GetAllUser().Where(x => x.GroupID == groupId).ToList();
|
||||||
|
|
||||||
|
var presenceByGroup = _repositoryPresenceImpl.GetPresenceByGroup(groupId)
|
||||||
|
.Where(x => users.Any(user => user.Guid == x.UserGuid))
|
||||||
|
.Select(presence => new Presence{
|
||||||
|
User = new User{
|
||||||
|
Guid = presence.UserGuid,
|
||||||
|
GroupId = new Group{
|
||||||
|
Id = groupId,
|
||||||
|
Name = _repositoryGroupImpl.GetAllGroup().First(group => group.Id == groupId).Name
|
||||||
|
},
|
||||||
|
FIO = users.First(user => user.Guid == presence.UserGuid).FIO,
|
||||||
|
},
|
||||||
|
ClassNumber = presence.ClassNumber,
|
||||||
|
Date = presence.Date,
|
||||||
|
IsAttendence = presence.IsAttendence
|
||||||
|
}).ToList();
|
||||||
|
return presenceByGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Presence> GetPresenceByGroupAndDate(int groupId, DateOnly date) {
|
||||||
|
var users = _repositoryUserImpl.GetAllUser().Where(x => x.GroupID == groupId).ToList();
|
||||||
|
|
||||||
|
var presenceByGroupAndDate = _repositoryPresenceImpl.GetPresenceByGroupAndDate(groupId, date)
|
||||||
|
.Where(x => users.Any(user => user.Guid == x.UserGuid && x.Date == date))
|
||||||
|
.Select(presence => new Presence{
|
||||||
|
User = new User{
|
||||||
|
Guid = presence.UserGuid,
|
||||||
|
GroupId = new Group{
|
||||||
|
Id = groupId,
|
||||||
|
Name = _repositoryGroupImpl.GetAllGroup().First(group => group.Id == groupId).Name
|
||||||
|
},
|
||||||
|
FIO = users.First(user => user.Guid == presence.UserGuid).FIO,
|
||||||
|
},
|
||||||
|
ClassNumber = presence.ClassNumber,
|
||||||
|
Date = presence.Date,
|
||||||
|
IsAttendence = presence.IsAttendence
|
||||||
|
}).ToList();
|
||||||
|
return presenceByGroupAndDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UncheckAttendence(PresenceLocalEntity presence) {
|
||||||
|
return _repositoryPresenceImpl.UncheckAttendence(presence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Posechaemost.Data.LocalData.Entity;
|
|
||||||
using Posechaemost.Data.Repository;
|
|
||||||
using Posechaemost.Domain.Models;
|
|
||||||
|
|
||||||
namespace Posechaemost.Domain.UseCase
|
|
||||||
{
|
|
||||||
public class UseCasePresence
|
|
||||||
{
|
|
||||||
private readonly PresenceRepositoryImpl _repositoryPresenceImpl;
|
|
||||||
private readonly UserRepositoryImpl _repositoryUserImpl;
|
|
||||||
private readonly GroupRepositoryImpl _repositoryGroupImpl;
|
|
||||||
|
|
||||||
public UseCasePresence(PresenceRepositoryImpl repositoryImpl, UserRepositoryImpl userRepositoryImpl, GroupRepositoryImpl groupRepositoryImpl) {
|
|
||||||
_repositoryPresenceImpl = repositoryImpl;
|
|
||||||
_repositoryUserImpl = userRepositoryImpl;
|
|
||||||
_repositoryGroupImpl = groupRepositoryImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Posechaemost")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("Posechaemost")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4105b8029769b2ea442771dc29b948bad308afc9")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6b32e405d76bb739524c318b227f1fa95db1cba6")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("Posechaemost")]
|
[assembly: System.Reflection.AssemblyProductAttribute("Posechaemost")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("Posechaemost")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("Posechaemost")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
@ -1 +1 @@
|
|||||||
2d28f4118d0518446dabfbd87d6de7e33862a518a80b4f754a0e37e26437422d
|
4adf1b2c58c78e6eafd52a8be1c408433fb9f4a3525dbf62f4e5019169eebcab
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
"privateAssets": "all"
|
"privateAssets": "all"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.402/PortableRuntimeIdentifierGraph.json"
|
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.403/PortableRuntimeIdentifierGraph.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2187,7 +2187,7 @@
|
|||||||
"privateAssets": "all"
|
"privateAssets": "all"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.402/PortableRuntimeIdentifierGraph.json"
|
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/8.0.403/PortableRuntimeIdentifierGraph.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"dgSpecHash": "gSN3MF76u68=",
|
"dgSpecHash": "Mj/MlEhPDCU=",
|
||||||
"success": true,
|
"success": true,
|
||||||
"projectFilePath": "/home/gara/csharp/Posechaemost/Posechaemost.csproj",
|
"projectFilePath": "/home/gara/csharp/Posechaemost/Posechaemost.csproj",
|
||||||
"expectedPackageFiles": [
|
"expectedPackageFiles": [
|
||||||
|
Loading…
Reference in New Issue
Block a user