public async Task <IActionResult> Edit(int id) { var alarmEntity = await alarmRepository.Get(id); var alarmVM = mapper.Map <SampleTimeViewModel>(alarmEntity); return(View(alarmVM)); }
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)); }
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) }); }
public IActionResult Get(int id) { return(Ok(repo.Get(id))); }