namespace MyOffice.Data.Repositories.Motion;

using Microsoft.EntityFrameworkCore;
using Models.Motions;

public class MotionCategoryRepository : AppRepository<MotionCategory>, IMotionCategoryRepository
{
	public List<MotionCategory> GetAll(Guid userId)
	{
		return _context.MotionCategories
			.Include(x => x.Motions)
			.Where(x => x.UserId == userId)
			.ToList();
	}

	public bool Add(MotionCategory motionCategory)
	{
		return AddBase(motionCategory) > 0;
	}

	public MotionCategory? Get(Guid userId, Guid id)
	{
		return _context.MotionCategories
			.Include(x => x.Motions)
			.FirstOrDefault(x => x.Id == id && x.UserId == userId);
	}

	public bool Update(MotionCategory motionCategory)
	{
		return UpdateBase(motionCategory) > 0;
	}

	public bool Remove(MotionCategory motionCategory)
	{
		return RemoveBase(motionCategory) > 0;
	}
}