public bool CheckExistanceOfUserPlan(string userId) { //unitOfWork.StartTransaction(); UserPlanRepository repo = new UserPlanRepository(unitOfWork); UserPlan userPlan = new UserPlan(); userPlan = repo.GetAll().Where(x => x.UserId == userId).FirstOrDefault(); //unitOfWork.Commit(); if (userPlan != null) { return true; } else { return false; } }
public UserPlanModel GetUserPlanByUserId(string userId) { //unitOfWork.StartTransaction(); UserPlanRepository repo = new UserPlanRepository(unitOfWork); UserPlanModel userPlanModel = new UserPlanModel(); UserPlan userPlan = new UserPlan(); userPlan = repo.GetAll().Where(x=>x.UserId==userId && x.ExpiredDate > DateTime.UtcNow).FirstOrDefault(); //if (userPlan == null) //{ // UserPlan checkPlan = new UserPlan(); // checkPlan = repo.GetAll().Where(x => x.UserId == userId).FirstOrDefault(); // repo.Delete(x=>x.Id== checkPlan.Id); //} //unitOfWork.Commit(); AutoMapper.Mapper.Map(userPlan, userPlanModel); return userPlanModel; }