示例#1
0
 public void DeleteSubService(int serviceId)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     repo.Delete(x => x.ServiceId == serviceId);
     //unitOfWork.Commit();
 }
示例#2
0
 public List<SubServiceModel> GetAllSubServices()
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
        List<SubServiceModel> subServiceList = new List<SubServiceModel>();
        List<Service> service = new List<Service>();
     AutoMapper.Mapper.Map(subServiceList, service);
     service = repo.GetAll().Where(x=>x.ServiceCategoryId != null).OrderByDescending(X=>X.ServiceId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, subServiceList);
     return subServiceList;
 }
示例#3
0
 public SubServiceModel GetAllCategoryServiceByServiceId(int ServiceId)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     SubServiceModel subServiceList = new SubServiceModel();
     Service service = new Service();
     AutoMapper.Mapper.Map(subServiceList, service);
     service = repo.GetAll().Where(x => x.ServiceId == ServiceId).FirstOrDefault();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, subServiceList);
     return subServiceList;
 }
示例#4
0
 public bool CheckExistance(int serviceId)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     var service = repo.GetAll().Where(x => x.ServiceId == serviceId).Count();
     //unitOfWork.Commit();
     if (service > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#5
0
 public List<SubServiceModel> GetAllActualServiceByServiceId(int serviceId=0)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     List<SubServiceModel> subServiceList = new List<SubServiceModel>();
     List<Service> service = new List<Service>();
     AutoMapper.Mapper.Map(subServiceList, service);
     if (serviceId > 0)
     {
         service = repo.GetAll().Where(x => x.ServiceCategoryId == null && x.ParentServiceId == serviceId).OrderByDescending(X => X.ServiceId).ToList();
     }
     else
     {
         service = repo.GetAll().Where(x => x.ServiceCategoryId != null).OrderByDescending(X => X.ServiceId).ToList();
     }
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, subServiceList);
     return subServiceList;
 }
示例#6
0
 public List<SubServiceModel> GetAllSubServicesByCategoryServiceId(int CategoryServiceId)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     List<SubServiceModel> subServiceList = new List<SubServiceModel>();
     List<Service> service = new List<Service>();
     AutoMapper.Mapper.Map(subServiceList, service);
     service = repo.GetAll().Where(x => x.ServiceCategoryId == CategoryServiceId).ToList();
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, subServiceList);
     return subServiceList;
 }
示例#7
0
 public SubServiceModel UpadteSubService(SubServiceModel model)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     Service service = new Service();
     service = repo.GetAll().Where(x => x.ServiceId == model.ServiceId).FirstOrDefault();
     AutoMapper.Mapper.Map(model, service);
     repo.Update(service);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, model);
     return model;
 }
示例#8
0
 public SubServiceModel SaveSubService(SubServiceModel model)
 {
     //unitOfWork.StartTransaction();
     SubServiceRepository repo = new SubServiceRepository(unitOfWork);
     Service service = new Service();
     AutoMapper.Mapper.Map(model, service);
     repo.Insert(service);
     //unitOfWork.Commit();
     AutoMapper.Mapper.Map(service, model);
     return model;
 }
示例#9
0
        public List<SubServiceModel> GetServicesByCategoryId(int categoryId = 0)
        {
            //unitOfWork.StartTransaction();
            SubServiceRepository repo = new SubServiceRepository(unitOfWork);
            List<SubServiceModel> subServicesModel = new List<SubServiceModel>();
            List<Service> services = new List<Service>();
            AutoMapper.Mapper.Map(subServicesModel, services);
            var subServices = repo.GetAll().Where(x => x.ServiceCategoryId == categoryId).ToList();
            var subServiceIds = subServices.Select(x => Convert.ToInt32(x.ServiceId)).ToArray();
            var actualServices = repo.GetAll().Where(x => x.ServiceCategoryId == null && subServiceIds.Contains(Convert.ToInt32(x.ParentServiceId))).ToList();
            services = subServices.Concat(actualServices).ToList();

            //unitOfWork.Commit();
            AutoMapper.Mapper.Map(services, subServicesModel);
            return subServicesModel;
        }