Files
constructdemo/ConstructorApp.DataAccessLayer/EntityFramework/EfTestimonialDal.cs
2025-05-01 15:18:30 +03:00

36 lines
1.1 KiB
C#

using ConstructorApp.DataAccessLayer.Abstract;
using ConstructorApp.DataAccessLayer.Concrete;
using ConstructorApp.DataAccessLayer.Repositories;
using ConstructorApp.EntityLayer.Entities;
namespace ConstructorApp.DataAccessLayer.EntityFramework
{
public class EfTestimonialDal : GenericRepository<Testimonial>, ITestimonialDal
{
private readonly ConstructorContext context;
public EfTestimonialDal(ConstructorContext context) : base(context)
{
this.context = context;
}
public int CountAll()
{
return context.Testimonials.Count(x => x.Status != TestimonialStatus.Cancelled);
}
public void TestimonialStatusActive(int id)
{
var values = context.Testimonials.Find(id);
values.Status = TestimonialStatus.Confirmed;
context.SaveChanges();
}
public void TestimonialStatusPassive(int id)
{
var values = context.Testimonials.Find(id);
values.Status = TestimonialStatus.Cancelled;
context.SaveChanges();
}
}
}