Skip to main content
Code Review

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I posted the original question here here, but I think it would be nice to have someone else's eye on this code for improving it.

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.

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.

deleted 14 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

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

added 1159 characters in body
Source Link
Sirwan Afifi
  • 533
  • 1
  • 4
  • 14

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();
 }
}
Source Link
Sirwan Afifi
  • 533
  • 1
  • 4
  • 14
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /