presenceController

This commit is contained in:
Your Name 2024-11-11 14:49:39 +03:00
parent f3b6d3ae0b
commit 6c6c0936f5
45 changed files with 180 additions and 14 deletions

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("console_ui")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9a1a4a676f43477d6c758020bf8a6f3c550c7d1f")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f3b6d3ae0b55a58f9494d04bfeb66c0114a08395")]
[assembly: System.Reflection.AssemblyProductAttribute("console_ui")]
[assembly: System.Reflection.AssemblyTitleAttribute("console_ui")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
93963eb25804405d79459648470cd299e68efdc112b75ac96b547535eb75b4dd
93dfdc7e462970a4fa2b898ff569f4de22ebb6efb11b9d888e185341a38fc581

View File

@ -6,6 +6,9 @@ namespace Demo.Data.Repository
{
List<PresenceLocalEntity> GetAllPresences();
bool DeletePresence();
bool DeletePresenceByGroup(int groupID);
bool DeletePresenceByUser(Guid userGuid);
bool DeletePresenceByRange(DateOnly start, DateOnly end);
void IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid);
List<PresenceLocalEntity> GeneratePresence(List<PresenceLocalEntity> presenceLocalEntities);
}

View File

@ -26,6 +26,27 @@ namespace Demo.Data.Repository
return true;
}
public bool DeletePresenceByGroup(int groupID){
var allRecords = _remoteDatabaseContext.PresenceDaos.Where(x => x.userDAO.GroupID == groupID).ToList();
_remoteDatabaseContext.PresenceDaos.RemoveRange(allRecords);
_remoteDatabaseContext.SaveChanges();
return true;
}
public bool DeletePresenceByRange(DateOnly start, DateOnly end)
{
var allRecords = _remoteDatabaseContext.PresenceDaos.Where(x => x.Date >= start && x.Date <= end).ToList();
_remoteDatabaseContext.PresenceDaos.RemoveRange(allRecords);
_remoteDatabaseContext.SaveChanges();
return true;
}
public bool DeletePresenceByUser(Guid userGuid){
var allRecords = _remoteDatabaseContext.PresenceDaos.Where(x => x.userDAO.Guid == userGuid).ToList();
_remoteDatabaseContext.PresenceDaos.RemoveRange(allRecords);
_remoteDatabaseContext.SaveChanges();
return true;
}
public List<PresenceLocalEntity> GeneratePresence(List<PresenceLocalEntity> presenceLocalEntities)
{
var presences = presenceLocalEntities.Select(x => new PresenceDAO

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("data")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ab663018abacf01e070b5ad828bf9b4512e0c4d7")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f3b6d3ae0b55a58f9494d04bfeb66c0114a08395")]
[assembly: System.Reflection.AssemblyProductAttribute("data")]
[assembly: System.Reflection.AssemblyTitleAttribute("data")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
cd43bf0997982c5c306bd1cf1db3c12e77ec46315653277fe2d342bd04c4db32
f258bbf320b2ab2f45e9951a8d2c1ff8ace7248d5e5c1d570f80701d61cb737b

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,6 +14,34 @@ namespace Demo.Domain.Models
public required int firstLesson {get; set; }
public required int lastLesson {get; set; }
public required int groupID {get; set; }
public required DateOnly date {get; set; }
public required string date {get; set; }
}
public class PresenceDeleteByRange
{
public required string start {get; set; }
public required string end {get; set; }
}
public class PresenceUpdate
{
public required int firstLesson {get; set;}
public required int lastLesson {get; set;}
public required string date {get; set;}
public required Guid UserGuid {get; set;}
}
public class PresenceRequest
{
public required string start {get; set;}
public required string end {get; set;}
public required int GruopID {get; set;}
public required Guid userGuid {get; set;}
}
public class PresenceGet
{
public required string gruop_name {get; set;}
public required List<UserForPresence> users {get; set;}
}
}

View File

@ -46,4 +46,12 @@ namespace Demo.Domain.Models
{
public List<Guid> UsersGuid { get; set; }
}
public class UserForPresence
{
public required string FIO {get; set;}
public required int lesson_number {get; set;}
public required DateOnly date {get; set;}
public required bool isAttendance {get; set;}
}
}

View File

@ -9,7 +9,11 @@ namespace Demo.Domain.UseCase
List<Presence> GetPresenceByUser(Guid userGuid);
List<Presence> GetFalsePresenceByUser(Guid userGuid);
List<Presence> GetFalsePresenceByGroup(int groupID);
PresenceGet GetPresencebyAll(int GroupID, DateOnly? start = null, DateOnly? end = null, Guid userGuid = default);
bool DeletePresence();
bool DeletePresenceByGroup(int groupID);
bool DeletePresenceByUser(Guid userGuid);
bool DeletePresenceByRange(DateOnly start, DateOnly end);
bool IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid);
bool GeneratePresence(int firstLesson, int lastLesson, int groupID, DateOnly date);
bool GeneratePresenceWeek(int firstLesson, int lastLesson, int groupID, DateOnly date);

View File

@ -130,10 +130,64 @@ namespace Demo.Domain.UseCase
return presenceByGroup;
}
public PresenceGet GetPresencebyAll(int GroupID, DateOnly? start = null, DateOnly? end = null, Guid userGuid = default){
IEnumerable<UserLocalEntity>? users = null;
if (userGuid == default)
{
users = _repositoryUserImpl.GetAllUser().Where(x => x.GroupID == GroupID);
} else {
users = _repositoryUserImpl.GetAllUser().Where(x => x.GroupID == GroupID && x.Guid == userGuid);
}
var usersFor = new List<UserForPresence>();
foreach(var user in users){
IEnumerable<PresenceLocalEntity> presences;
if (userGuid != default){
presences = _repositoryPresenceImpl.GetAllPresences().Where(x => x.UserGuid == userGuid).ToList();
}else{
presences = _repositoryPresenceImpl.GetAllPresences().ToList();
}
foreach(var presence in presences)
{
if (start.HasValue && end.HasValue)
{
if (presence.Date >= start && presence.Date <= end)
{
usersFor.Add(new UserForPresence{
FIO = user.FIO, lesson_number = presence.LessonNumber, date = presence.Date, isAttendance = presence.IsAttedance
});
}
} else
{
usersFor.Add(new UserForPresence{
FIO = user.FIO, lesson_number = presence.LessonNumber, date = presence.Date, isAttendance = presence.IsAttedance
});
}
}
}
var presenceGet = new PresenceGet{
gruop_name = _repositoryGroupImpl.GetAllGroup().FirstOrDefault(x => x.ID == GroupID).Name,
users = usersFor
};
return presenceGet;
}
public bool DeletePresence(){
return _repositoryPresenceImpl.DeletePresence();
}
public bool DeletePresenceByGroup(int groupID){
return _repositoryPresenceImpl.DeletePresenceByGroup(groupID);
}
public bool DeletePresenceByUser(Guid userGuid){
return _repositoryPresenceImpl.DeletePresenceByUser(userGuid);
}
public bool DeletePresenceByRange(DateOnly start, DateOnly end)
{
return _repositoryPresenceImpl.DeletePresenceByRange(start, end);
}
public bool IsAttedance(int firstLesson, int lastLesson, DateOnly date, Guid UserGuid){
_repositoryPresenceImpl.IsAttedance(firstLesson, lastLesson, date, UserGuid);
return true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("domain")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ab663018abacf01e070b5ad828bf9b4512e0c4d7")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f3b6d3ae0b55a58f9494d04bfeb66c0114a08395")]
[assembly: System.Reflection.AssemblyProductAttribute("domain")]
[assembly: System.Reflection.AssemblyTitleAttribute("domain")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Создано классом WriteCodeFragment MSBuild.
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +1 @@
53e90c69f33df0bd1e7077d29424b1847917acfabb5c61f6d56d7e56ca00c889
a97fc4fccec52337177679fc2cabe9bf83b4a407fbaa8b45e8ce331c9c202c1c

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,21 @@ public class PresenceController: ControllerBase{
//get
[HttpGet]
public ActionResult<PresenceGet> GetPresence(int groupID, string start = null, string end = null, Guid userGuid = default)
{
PresenceGet? presences = null;
if (start != null && end != null)
{
DateOnly.TryParse(start, out DateOnly start1);
DateOnly.TryParse(end, out DateOnly end1);
presences = _presenceUseCase.GetPresencebyAll(groupID, start1, end1, userGuid);
} else {
presences = _presenceUseCase.GetPresencebyAll(groupID, null, null, userGuid);
}
return Ok(presences);
}
//post
[HttpPost("generate")]
@ -24,11 +39,44 @@ public class PresenceController: ControllerBase{
if (request == null){
return BadRequest("buba");
}
var isGenerated = _presenceUseCase.GeneratePresence(request.firstLesson, request.lastLesson, request.groupID, request.date);
DateOnly.TryParse(request.date, out DateOnly date);
var isGenerated = _presenceUseCase.GeneratePresence(request.firstLesson, request.lastLesson, request.groupID, date);
return Ok(isGenerated);
}
//delete
[HttpDelete("gruop")]
public ActionResult<bool> DeletePresenceByGroup(int groupID)
{
var isDeleted = _presenceUseCase.DeletePresenceByGroup(groupID);
return isDeleted;
}
[HttpDelete("user")]
public ActionResult<bool> DeletePresenceByUser(Guid userGuid)
{
var isDeleted = _presenceUseCase.DeletePresenceByUser(userGuid);
return isDeleted;
}
[HttpDelete("range")]
public ActionResult<bool> DeletePresenceByRange([FromBody] PresenceDeleteByRange request)
{
DateOnly.TryParse(request.start, out DateOnly start);
DateOnly.TryParse(request.end, out DateOnly end);
var isDeleted = _presenceUseCase.DeletePresenceByRange(start, end);
return isDeleted;
}
//update
[HttpPatch]
public ActionResult<bool> UpdatePresence([FromBody] PresenceUpdate request)
{
DateOnly.TryParse(request.date, out DateOnly date);
var isDeleted = _presenceUseCase.IsAttedance(request.firstLesson, request.lastLesson, date, request.UserGuid);
return isDeleted;
}
}

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("presence_api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ab663018abacf01e070b5ad828bf9b4512e0c4d7")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f3b6d3ae0b55a58f9494d04bfeb66c0114a08395")]
[assembly: System.Reflection.AssemblyProductAttribute("presence_api")]
[assembly: System.Reflection.AssemblyTitleAttribute("presence_api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Создано классом WriteCodeFragment MSBuild.
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -1 +1 @@
e4838467133c57bdd2c94f8db0c1fd2159f424bc63563685da366c57ec64e107
059e4fe3c040ba5e4de8059d5b0cbbf5144c8ae5437fd528809cae631559f787

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ui")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9a1a4a676f43477d6c758020bf8a6f3c550c7d1f")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f3b6d3ae0b55a58f9494d04bfeb66c0114a08395")]
[assembly: System.Reflection.AssemblyProductAttribute("ui")]
[assembly: System.Reflection.AssemblyTitleAttribute("ui")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
33fa2290204bcc8a9ffbd9ebbafa0caa7d2c51ce6869d465b2b06327f393a747
da14eec68cbfc6fa33052b5f9e0c191fa5b6056cb645bca6e358d4f9d8de0ffc