I posted the original question here, Butbut I think it would be nice to have someone else's eye on this code for improving the code:it.
Update: MemberIntersetServiceMemberIntersetService
I posted the original question here, But I think it would be nice to have someone else's eye on this code for improving the code:
Update: MemberIntersetService
I posted the original question here, but I think it would be nice to have someone else's eye on this code for improving it.
MemberIntersetService
Update: MemberIntersetService
public class MemberInterestService : IMemberInterestService
{
public IQueryable<MemberInterest> Items { get { return _dbSet.Where(x => x.IsDeleted == false); } }
public MemberInterestService(AppDbContext dbContext) : base(dbContext)
{
_dbSet = dbContext.MemberInterests;
}
public bool IsSubInterestExist(Guid subInterestId)
{
return _dbSet.Any(p => p.InterestSubCategoryId == subInterestId);
}
public bool IsSubInterestExistInItem(Guid subInterestId)
{
return Items.Any(p => p.InterestSubCategoryId == subInterestId);
}
public void Delete(Guid interestId, Guid userProfileId, bool delete)
{
var item = _dbSet.Single(x => x.InterestSubCategoryId == interestId && x.UserProfileId == userProfileId);
//soft delete
item.IsDeleted = delete;
_dbSet.Update(item);
}
public IList<MemberInterestDto> GetAllPlusDeleted()
{
return _dbSet.Select(x => Mapper.Map<MemberInterest, MemberInterestDto>(x))
.ToList();
}
}
Update: MemberIntersetService
public class MemberInterestService : IMemberInterestService
{
public IQueryable<MemberInterest> Items { get { return _dbSet.Where(x => x.IsDeleted == false); } }
public MemberInterestService(AppDbContext dbContext) : base(dbContext)
{
_dbSet = dbContext.MemberInterests;
}
public bool IsSubInterestExist(Guid subInterestId)
{
return _dbSet.Any(p => p.InterestSubCategoryId == subInterestId);
}
public bool IsSubInterestExistInItem(Guid subInterestId)
{
return Items.Any(p => p.InterestSubCategoryId == subInterestId);
}
public void Delete(Guid interestId, Guid userProfileId, bool delete)
{
var item = _dbSet.Single(x => x.InterestSubCategoryId == interestId && x.UserProfileId == userProfileId);
//soft delete
item.IsDeleted = delete;
_dbSet.Update(item);
}
public IList<MemberInterestDto> GetAllPlusDeleted()
{
return _dbSet.Select(x => Mapper.Map<MemberInterest, MemberInterestDto>(x))
.ToList();
}
}