public List<SPKViewModel> SearchSPK(DateTime from, DateTime to, string LicenseNumber, string code, int category, DbConstant.ApprovalStatus approvalStatus, DbConstant.SPKPrintStatus printStatus, DbConstant.SPKCompletionStatus completedStatus, int isContractWork) { List<SPK> result = _SPKRepository.GetMany(spk => DbFunctions.TruncateTime(spk.CreateDate) >= DbFunctions.TruncateTime(from) && DbFunctions.TruncateTime(spk.CreateDate) <= DbFunctions.TruncateTime(to) && spk.Status == (int)DbConstant.DefaultDataStatus.Active && spk.CategoryReference.Code != DbConstant.REF_SPK_CATEGORY_SALE).ToList(); if ((int)completedStatus != 9) { result = result.Where(spk => spk.StatusCompletedId == (int)completedStatus).ToList(); } if ((int)printStatus != 9) { result = result.Where(spk => spk.StatusPrintId == (int)printStatus).ToList(); } if ((int)approvalStatus != 9) { result = result.Where(spk => spk.StatusApprovalId == (int)approvalStatus).ToList(); } if (!string.IsNullOrEmpty(LicenseNumber)) { VehicleDetail vehicleDetail = _vehicleDetailRepository.GetMany(v => string.Compare(v.LicenseNumber, LicenseNumber, true) == 1 && v.Status == (int)DbConstant.DefaultDataStatus.Active).FirstOrDefault(); if (vehicleDetail != null) { result = result.Where(spk => spk.VehicleId == vehicleDetail.VehicleId).ToList(); } } if (!string.IsNullOrEmpty(code)) { result = result.Where(spk => string.Compare(spk.Code, code, true) == 0).ToList(); } if (category > 0) { result = result.Where(spk => spk.CategoryReferenceId == category).ToList(); } if (isContractWork == 0) { result = result.Where(spk => spk.isContractWork == false).ToList(); } if (isContractWork == 1) { result = result.Where(spk => spk.isContractWork == true).ToList(); } List<SPKViewModel> mappedResult = new List<SPKViewModel>(); if (result == null) result = new List<SPK>(); return Map(result, mappedResult); }
public List<SparepartDetail> SearchSparepart(int sparepartId, DbConstant.SparepartDetailDataStatus status) { List<SparepartDetail> result = _sparepartDetailRepository.GetMany( spd => spd.SparepartId == sparepartId && spd.Status == (int)status).ToList(); return result; }
public List<SparepartDetailViewModel> SearchSparepart(int sparepartId, DbConstant.SparepartDetailDataStatus status, int purchaseDetailID) { List<SparepartDetail> result = new List<SparepartDetail>(); if (purchaseDetailID > 0) { result = _sparepartDetailRepository.GetMany( spd => spd.SparepartId == sparepartId && spd.Status == (int)status && spd.PurchasingDetailId == purchaseDetailID).ToList(); } else { result = _sparepartDetailRepository.GetMany( spd => spd.SparepartId == sparepartId && spd.Status == (int)status).ToList(); } List<SparepartDetailViewModel> mappedResult = new List<SparepartDetailViewModel>(); return Map(result, mappedResult); }
public List<PurchasingViewModel> SearchPurchasing(DateTime? dateFrom, DateTime? dateTo, DbConstant.PurchasingStatus purchasingStatus) { List<Purchasing> result = null; if (dateFrom.HasValue && dateTo.HasValue) { dateFrom = dateFrom.Value.Date; dateTo = dateTo.Value.Date.AddDays(1).AddSeconds(-1); result = _purchasingRepository.GetMany(c => c.Date >= dateFrom && c.Date <= dateTo && c.Status != (int) DbConstant.PurchasingStatus.Deleted).OrderBy(c => c.Date).ToList(); } else { result = _purchasingRepository.GetMany(c => c.Status != (int)DbConstant.PurchasingStatus.Deleted).OrderBy(c => c.Date).ToList(); } if ((int)purchasingStatus != 9) { result = result.Where(p => p.Status == (int)purchasingStatus).ToList(); } List<PurchasingViewModel> mappedResult = new List<PurchasingViewModel>(); return Map(result, mappedResult); }
public static bool IsAccessible(int accessCode, DbConstant.AccessTypeEnum accessType) { int defaultAction = (int)DbConstant.AccessTypeEnum.Read; defaultAction = defaultAction | accessCode; return defaultAction.Has(accessType); }
public static bool Has(this int accessCode, DbConstant.AccessTypeEnum flags) { return ((int)accessCode == ((int)flags | (int)accessCode)); }
public static bool Validate(this ModulInfo sender, DbConstant.AccessTypeEnum accessType) { if (sender != null) { return IsAccessible(sender.AccessCode, accessType); } return false; }
public List<SpecialSparepartDetailViewModel> SearchDetail(int specialSparepartId, DbConstant.WheelDetailStatus status) { List<SpecialSparepartDetail> result = _specialSparepartDetailRepository.GetMany(whd => whd.Status == (int)status && whd.SpecialSparepartId == specialSparepartId).ToList(); List<SpecialSparepartDetailViewModel> mappedResult = new List<SpecialSparepartDetailViewModel>(); return Map(result, mappedResult); }
public List<InvoiceViewModel> SearchInvoice(DateTime? dateFrom, DateTime? dateTo, DbConstant.InvoiceStatus invoiceStatus, int customerId, int paymentStatus) { List<Invoice> result = null; if (dateFrom.HasValue && dateTo.HasValue) { dateFrom = dateFrom.Value.Date; dateTo = dateTo.Value.Date.AddDays(1).AddSeconds(-1); result = _invoiceRepository.GetMany(c => c.CreateDate >= dateFrom && c.CreateDate <= dateTo).OrderBy(c => c.CreateDate).ToList(); } else { result = _invoiceRepository.GetAll().OrderBy(c => c.CreateDate).ToList(); } if ((int)invoiceStatus != 9) { result = result.Where(spk => spk.Status == (int)invoiceStatus).ToList(); } if(customerId > 0) { result = result.Where(inv => inv.SPK.Vehicle.CustomerId == customerId).ToList(); } if(paymentStatus > -1) { result = result.Where(inv => inv.PaymentStatus == paymentStatus).ToList(); } List<InvoiceViewModel> mappedResult = new List<InvoiceViewModel>(); return Map(result, mappedResult); }