public ViewResult Index(long id /*logical object identifier*/, long deviceid /*physical device identifier*/, long logicaldeviceid) { try { ViewBag.DeviceID = deviceid; ViewBag.ObjectID = id; ViewBag.LogicalDeviceID = logicaldeviceid; Guid userId = GetUserId(); ViewDevice viewdevice = _deviceRepository.GetDevice(deviceid, userId); ViewBag.DeviceName = viewdevice.Name; ViewDeviceType viewdevicetype = _deviceTypeRepository.GetDeviceType(viewdevice.TypeID, userId); ViewBag.DeviceTypeName = viewdevicetype.Description.TrimEnd(); ViewCOSEMObject viewcosemobject = _cosemObjectRepository.GetCosemObject(id, userId); ViewBag.ObjectName = viewcosemobject.COSEMLogicalName; List <ViewCOSEMAttributeValue> viewcosemattribute = _cosemAttributeRepository.GetCosemAttributeValueList(deviceid, viewcosemobject.ID, viewcosemobject.COSEMClassID, userId); return(View(viewcosemattribute)); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
private void FillCreateEditViewBag(long id /*the identifier of COSEM logical device*/) { // some other things are filled that impossible to pass through model object. ViewCOSEMLogicalDevice viewcosemlogicaldevice = _cosemLogicaDeviceRepository.GetCosemLogicalDevice(id, GetUserId()); ViewDeviceType vdt = _deviceTypeRepository.GetDeviceType(viewcosemlogicaldevice.DeviceTypeID, GetUserId()); ViewBag.DeviceTypeName = vdt.Description.TrimEnd(); // list of COSEM classes is extracted ViewBag.COSEMClassID = _cosemClassRepository.GetCosemClasses(GetUserId(), 0); }
public ViewResult Details(long id) { try { ViewDeviceType viewdevicetype = _repository.GetDeviceType(id, GetUserId()); return(View(viewdevicetype)); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
public ViewResult Index(long id /*идентификатор физического устройства*/) { try { Guid userId = GetUserId(); ViewDevice viewdevice = _deviceRepository.GetDevice(id, userId); ViewBag.DeviceTypeID = viewdevice.TypeID; ViewBag.DeviceName = viewdevice.Name; ViewBag.DeviceGroupID = viewdevice.GroupID; ViewBag.DeviceID = id; ViewDeviceType viewdevicetype = _deviceTypeRepository.GetDeviceType(viewdevice.TypeID, userId); ViewBag.DeviceTypeName = viewdevicetype.Description.TrimEnd(); List <ViewCOSEMLogicalDevice> viewcosemlogicaldevice = _cosemLogicalDeviceRepository.GetCosemLogicalDeviceList(viewdevice.TypeID, userId); return(View(viewcosemlogicaldevice)); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
private void FillAuxData(long id /*идентификатор типа физического устройства*/) { ViewDeviceType vdt = _deviceTypeRepository.GetDeviceType(id, GetUserId()); ViewBag.DeviceTypeName = vdt.Description.TrimEnd(); ViewBag.DeviceTypeID = id; }
public async Task <IActionResult> CreateOrUpdateDeviceType(DeviceTypeToCreateOrUpdate deviceTypeDto) { if (deviceTypeDto == null) { return(BadRequest()); } if (deviceTypeDto.Id == null) { //ovaj blok se izvrsava ukoliko je u pitanju kreiranje tipa uredjaja var deviceType = _mapper.Map <DeviceType>(deviceTypeDto); _repo.CreateDeviceType(deviceType); if (await _repo.SaveAll()) { var deviceTypeFromRepo = await _repo.GetDeviceType(deviceType.Id); var deviceTypeToReturn = _mapper.Map <DeviceTypeToReturnSingleDto>(deviceTypeFromRepo); return(CreatedAtRoute("GetDeviceType", new { id = deviceTypeFromRepo.Id }, deviceTypeToReturn)); } throw new Exception("Creating device type failed on save"); } else { //ovaj blok se izvrsava ukoliko je u pitanju update tipa uredjaja var deviceTypeToUpdate = _mapper.Map <DeviceType>(deviceTypeDto); _repo.UpdateDeviceType(deviceTypeToUpdate); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception("Updating device type failed on save"); } }
public async Task <IActionResult> GetDeviceType() { try { var result = await _repository.GetDeviceType(); var devices = _mapper.Map <List <DeviceTypeDTO> >(result); return(Ok(devices)); } catch (Exception ex) { return(BadRequest(ex)); } }
public ViewResult Index(long id /*logical device identifier*/, long deviceid /*physical device identifier*/) { try { ViewBag.DeviceID = deviceid; ViewBag.LogicalDeviceID = id; Guid userId = GetUserId(); ViewDevice viewdevice = _deviceRepository.GetDevice(deviceid, userId); ViewBag.DeviceName = viewdevice.Name; ViewDeviceType viewdevicetype = _deviceTypeRepository.GetDeviceType(viewdevice.TypeID, userId); ViewBag.DeviceTypeName = viewdevicetype.Description.TrimEnd(); List <ViewCOSEMObject> viewcosemobject = _cosemObjectRepository.GetCosemObjectList(id, userId); return(View(viewcosemobject)); } catch (Exception e) { ExceptionMessageToViewBag(e); return(View("Error")); } }
private void FillAuxData(ViewOBISSet viewobisset) { Guid userId = GetUserId(); if (viewobisset != null) { if (viewobisset.DeviceTypeID != null) { ViewDeviceType vdt = _deviceTypeRepository.GetDeviceType((Int64)viewobisset.DeviceTypeID, userId); ViewBag.DeviceTypeName = vdt.Description; } } if (viewobisset != null && viewobisset.DeviceTypeID != null) { ViewBag.DeviceTypeID = _deviceTypeRepository.GetDeviceTypes(userId, (Int64)viewobisset.DeviceTypeID, null); } ViewBag.AID = _obisGroupRepository.GetObisGroups("A", userId, viewobisset != null ? viewobisset.AID : 0); ViewBag.BID = _obisGroupRepository.GetObisGroups("B", userId, viewobisset != null ? viewobisset.BID : 0); ViewBag.CID = _obisGroupRepository.GetObisGroups("C", userId, viewobisset != null ? viewobisset.CID : 0); ViewBag.DID = _obisGroupRepository.GetObisGroups("D", userId, viewobisset != null ? viewobisset.DID : 0); ViewBag.EID = _obisGroupRepository.GetObisGroups("E", userId, viewobisset != null ? viewobisset.EID : 0); ViewBag.FID = _obisGroupRepository.GetObisGroups("F", userId, viewobisset != null ? viewobisset.FID : 0); }