Demo/Domain/UseCase/GroupUseCase.cs

36 lines
1.2 KiB
C#
Raw Normal View History

using Posechaemost.Data.LocalData.Entity;
using Posechaemost.Data.Repository;
using Posechaemost.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Posechaemost.Domain.UseCase
{
public class GroupUseCase
{
private GroupRepositoryImpl _repositoryGroupImpl;
public GroupUseCase(GroupRepositoryImpl repositoryGroupImpl)
{
_repositoryGroupImpl = repositoryGroupImpl;
}
public List<Group> GetAllGroups() => _repositoryGroupImpl.GetAllGroups()
.Select(it => new Group { Id = it.Id, Name = it.Name}).ToList();
public Group UpdateGroupName(String name, String name1) {
GroupLocalEntity? result = _repositoryGroupImpl.UpdateGroup(name);
if (result == null) throw new Exception("");
Group? group = GetAllGroups().FirstOrDefault(it => it.Name == result.Name);
if (group == null) throw new Exception("");
return new Group {Id = group.Id, Name = name1};
}
2024-10-18 08:43:40 +00:00
public GroupLocalEntity AddGroup(String name, String id)
{
return _repositoryGroupImpl.AddGroup(name, id);
}
}
}