public UserPlanModel InsertUserPlan(UserPlanModel planModel) { //unitOfWork.StartTransaction(); UserPlanRepository repo = new UserPlanRepository(unitOfWork); //UserLocationModel userLocationModel = new UserLocationModel(); UserPlan userPlan = new UserPlan(); AutoMapper.Mapper.Map(planModel, userPlan); userPlan = repo.Insert(userPlan); //unitOfWork.Commit(); AutoMapper.Mapper.Map(userPlan, planModel); return planModel; }
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; }
public UserPlanService() { _repository = new UserPlanRepository(); }