Пример #1
0
        public async Task <IActionResult> Edit(int id)
        {
            var alarmEntity = await alarmRepository.Get(id);

            var alarmVM = mapper.Map <SampleTimeViewModel>(alarmEntity);

            return(View(alarmVM));
        }
Пример #2
0
        public async Task <StatusCodeResult> Delete(int id)
        {
            var alarm = await alarmRepository.Get(id);

            if (alarm == null)
            {
                return(NotFound());
            }

            bool res = await alarmRepository.Delete(id);

            if (res)
            {
                return(Ok());
            }

            return(StatusCode(500));
        }
Пример #3
0
        public PaginatedItems <Alarm> GetAll(IMongoFilter <Device, Alarm> filter, int rowsPerPage, int pageNumber)
        {
            DeviceAlarmFilter alarmFilter = new DeviceAlarmFilter
            {
                Context   = (filter as AlarmFilter).Context,
                AlarmType = (filter as AlarmFilter).AlarmType,
                Gravity   = (filter as AlarmFilter).Gravity,
                DeviceId  = string.Empty,
                IsRead    = (filter as AlarmFilter).IsRead,
                IsActive  = (filter as AlarmFilter).IsActive
            };

            var totalCount = alarmRepository.Count(alarmFilter);
            var pageCount  = rowsPerPage == 0 ? 1 : (int)Math.Ceiling((double)totalCount / rowsPerPage);

            return(new PaginatedItems <Alarm>
            {
                PageCount = pageCount,
                TotalItemsCount = totalCount,
                Items = alarmRepository.Get(alarmFilter, rowsPerPage, pageNumber)
            });
        }
Пример #4
0
 public IActionResult Get(int id)
 {
     return(Ok(repo.Get(id)));
 }