public PagedResultDto <FieldDto> GetAll(PagedSortedAndFilteredInputDto input) { var query = _fieldRepository.GetAll().Where(f => f.IsDeleted == false).Include(f => f.Device); var total = query.Count(); var result = input.Sorting != null ? query.OrderBy(input.Sorting).AsNoTracking().PageBy(input).ToList() : query.PageBy(input).ToList(); return(new PagedResultDto <FieldDto>(total, ObjectMapper.Map <List <FieldDto> >(result))); }
public TableResultJson <FieldViewModel> GetAllField(TableRequest request) { var dataSource = fieldRepository.GetAll().OrderByDescending(x => x.CreatedDate); var dataSourceViewModel = mapper.Map <List <FieldViewModel> >(dataSource).AsEnumerable(); var response = new TableResultJson <FieldViewModel> { draw = request.draw, recordsFiltered = dataSourceViewModel.Count() }; dataSourceViewModel = dataSourceViewModel.Skip(request.start).Take(request.length); response.data = dataSourceViewModel.ToList(); response.data.ForEach(x => { x.Index = response.data.IndexOf(x) + request.start + 1; }); return(response); }
public async Task <IActionResult> Get() { return(await FunctionWrapper.ExecuteFunction(this, async() => { return await _fieldRepository.GetAll(); })); }
public IEnumerable <Application> GetApplications() { return(cachingService.GetOrSet("Applications", () => { var applications = applicationRepository.GetAll().ToList(); var fields = fieldRepository.GetAll().ToList(); var databases = databaseRepository.GetAll().ToList(); foreach (var app in applications) { app.DBSchema = databases.FirstOrDefault(a => a.ID == app.IDDatabase)?.DBSchema; app.Fields = fields.Where(a => a.IDApplication == app.ID && string.IsNullOrEmpty(a.ShowInView)).ToArray(); app.FieldsItems = fields.Where(a => a.IDApplication == app.ID && a.ShowInView == "Items").ToArray(); app.FieldsSummary = fields.Where(a => a.IDApplication == app.ID && a.ShowInView == "Summary").ToArray(); app.FieldsComment = fields.Where(a => a.IDApplication == app.ID && a.ShowInView == "Comment").ToArray(); if (!string.IsNullOrEmpty(app.CustomData)) { try { app.Custom = app.CustomData.DeserializeJSON <AppCustomData>(); } catch (Exception ex) { } } } return applications; })); }
public ThresholdDto Create(ThresholdDto input) { var thresholdQuery = _thresholdRepository.GetAll().Where(t => t.RuleName == input.RuleName); if ((thresholdQuery.Any()) && (thresholdQuery.FirstOrDefault().IsDeleted == true)) { var entity = thresholdQuery.FirstOrDefault(); entity.IsDeleted = false; var result_old = _thresholdRepository.Update(entity); CurrentUnitOfWork.SaveChanges(); return(ObjectMapper.Map <ThresholdDto>(result_old)); } if (thresholdQuery.Any()) { throw new ApplicationException("threshold 已存在"); } var fieldQuery = _fieldRepository.GetAll().Where(f => f.FieldName == input.FieldName); if (!fieldQuery.Any()) { throw new ApplicationException("field 不存在"); } var severityQuery = _severityRepository.GetAll().Where(s => s.SeverityName == input.SeverityName); if (!severityQuery.Any()) { throw new ApplicationException("severity 不存在"); } var field = fieldQuery.FirstOrDefault(); var severity = severityQuery.FirstOrDefault(); var threshold = new Threshold() { Field = field, Operator = input.Operator, RuleName = input.RuleName, Severity = severity, Id = input.Id, ThresholdValue = input.ThresholdValue, Description = input.Description }; var result = _thresholdRepository.Insert(threshold); CurrentUnitOfWork.SaveChanges(); return(ObjectMapper.Map <ThresholdDto>(result)); }
public ViewResult Index() { ViewData["Bunkers"] = bunkerRepository.GetAll(); ViewData["Fields"] = fieldRepository.GetAll(); ViewData["LayoutTemplates"] = layoutTemplateRepository.GetAll(); Layout layout = new Layout(); return(View(layout)); }
public IEnumerable <Field> GetAll(BaseGetAllRequest request) { var data = fieldRepository.GetAll().Where(x => x.Status == ItemStatus.Active); if (request.Count.HasValue && request.Skip.HasValue) { data = data.Skip(request.Skip.Value).Take(request.Count.Value); } return(data); }
public List <object> GetFieldOptions() { var deviceQuery = _deviceRepository.GetAll().Where(d => d.IsDeleted == false); List <Device> devices1 = deviceQuery.ToList(); List <DeviceDto> devices = ObjectMapper.Map <List <DeviceDto> >(devices1); List <object> result = new List <object>(); foreach (DeviceDto d in devices) { var fieldQuery = _fieldRepository.GetAll().Where(f => f.IsDeleted == false).Where(f => f.DeviceId == d.Id); List <Field> fields1 = fieldQuery.ToList(); List <FieldDto> fields = ObjectMapper.Map <List <FieldDto> >(fields1); List <object> children = new List <object>(); foreach (var f in fields) { children.Add(new { value = f.IndexId, label = f.FieldName }); } result.Add(new { value = d.HardwareId, label = d.DeviceName, children = children }); } return(result); }
public List <Field> GetFields(SubCategory subCategory) { return(_fieldRep.GetAll().Where(x => x.SubCategoryId == subCategory.Id).ToList()); }
public List <Field> GetAll() { return(fieldRepository.GetAll().ToList()); }
public IHttpActionResult GetFields() { var fields = _fieldRepository.GetAll(); return(ApiOk(fields)); }
public IEnumerable <Field> Get() { return(_fieldRepository.GetAll()); }
public IEnumerable <FieldEntity> GetSubFields(int?fieldId) { return(fieldRepository.GetAll() .Where(f => f.ParentId == fieldId) .Select(f => f.ToBllField())); }
public async Task <IEnumerable <FieldViewModel> > GetAll() { var result = await _fieldRepository.GetAll(); return(result.Select(_mapper.Map <FieldViewModel>)); }
public IQueryable <Field> GetAll() { return(_fieldRepositories.GetAll()); }