예제 #1
0
        // POST api/customers
        public HttpResponseMessage Post([FromBody] Rld.Acs.Model.TimeZone timeZoneInfo)
        {
            return(ActionWarpper.Process(timeZoneInfo, OperationCodes.ATMZN, () =>
            {
                var timeZoneRepo = RepositoryManager.GetRepository <ITimeZoneRepository>();
                var timeZoneGroupRepo = RepositoryManager.GetRepository <ITimeZoneGroupRepository>();
                var timeGroupRepo = RepositoryManager.GetRepository <ITimeGroupRepository>();

                if (timeZoneInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "timeZoneInfo is null");
                }

                if (timeZoneRepo.Query(new Hashtable()
                {
                    { "TimeZoneCode", timeZoneInfo.TimeZoneCode }
                }).Any())
                {
                    return new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(string.Format("系统中已经存在编号为{0}的时间区", timeZoneInfo.TimeZoneCode)),
                        ReasonPhrase = ConstStrings.BusinessLogicError,
                    };
                }

                timeZoneRepo.Insert(timeZoneInfo);
                timeZoneInfo.TimeGroupAssociations.ForEach(t => t.TimeZoneID = timeZoneInfo.TimeZoneID);
                timeZoneInfo.TimeGroupAssociations.ForEach(t => timeZoneGroupRepo.Insert(t));

                return Request.CreateResponse(HttpStatusCode.OK, timeZoneInfo);
            }, this));
        }
예제 #2
0
        // DELETE api/customer/5
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DTMGP, () =>
            {
                var timeGroupRepo = RepositoryManager.GetRepository <ITimeGroupRepository>();
                var timeGroupSegmentRepo = RepositoryManager.GetRepository <ITimeGroupSegmentRepository>();
                var timeZoneGroupRepo = RepositoryManager.GetRepository <ITimeZoneGroupRepository>();

                var timeZoneGroupBindings = timeZoneGroupRepo.Query(new Hashtable {
                    { "TimeGroupID", id }
                });
                if (timeZoneGroupBindings.Any())
                {
                    return Request.CreateResponse(HttpStatusCode.BadGateway, "TimeGroup has binding to TimeZone, cannot be deleted utill the bindings are clean.");
                }

                var timeGroupInfo = timeGroupRepo.GetByKey(id);
                if (timeGroupInfo != null)
                {
                    var bindings = timeGroupSegmentRepo.Query(new Hashtable {
                        { "TimeGroupID", id }
                    }).ToList();
                    bindings.ForEach(b => timeZoneGroupRepo.Delete(b.TimeGroupSegmentID));
                    timeGroupRepo.Delete(id);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #3
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QDVOPLOG, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceOperationLogRepository>();

                IEnumerable <DeviceOperationLog> deviceOperationLogInfos;
                if (conditions.ContainsKey(ConstStrings.PageStart) && conditions.ContainsKey(ConstStrings.PageEnd))
                {
                    var paginationResult = repo.QueryPage(conditions);
                    var totalCount = paginationResult.TotalCount;
                    deviceOperationLogInfos = paginationResult.Entities;
                    System.Web.HttpContext.Current.Response.Headers.Add(ConstStrings.HTTP_HEADER_X_Pagination_TotalCount, totalCount.ToString());
                }
                else
                {
                    deviceOperationLogInfos = repo.Query(conditions);
                }


                return Request.CreateResponse(HttpStatusCode.OK, deviceOperationLogInfos.ToList());
            }, this));
        }
예제 #4
0
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DDV, () =>
            {
                var deviceControllerParameterRepo = RepositoryManager.GetRepository <IDeviceControllerParameterRepository>();
                var deviceDoorRepo = RepositoryManager.GetRepository <IDeviceDoorRepository>();
                var deviceHeadReadingRepo = RepositoryManager.GetRepository <IDeviceHeadReadingRepository>();
                var deviceRepo = RepositoryManager.GetRepository <IDeviceControllerRepository>();

                var deviceInfo = deviceRepo.GetByKey(id);
                if (deviceInfo != null)
                {
                    deviceControllerParameterRepo.Delete(deviceInfo.DeviceControllerParameter.DeviceParameterID);

                    if (deviceInfo.DeviceDoors.Any())
                    {
                        deviceInfo.DeviceDoors.ForEach(r => deviceDoorRepo.Delete(r.DeviceDoorID));
                    }

                    if (deviceInfo.DeviceHeadReadings.Any())
                    {
                        deviceInfo.DeviceHeadReadings.ForEach(h => deviceHeadReadingRepo.Delete(h.DeviceHeadReadingID));
                    }

                    deviceRepo.Delete(id);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #5
0
        public HttpResponseMessage Post([FromBody] Department departmentInfo)
        {
            return(ActionWarpper.Process(departmentInfo, OperationCodes.ADEPT, () =>
            {
                var departmentRepo = RepositoryManager.GetRepository <IDepartmentRepository>();
                var departmentDeviceRepo = RepositoryManager.GetRepository <IDepartmentDeviceRepository>();

                if (departmentInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "departmentInfo is null");
                }

                if (departmentInfo.Parent == null)
                {
                    departmentInfo.Parent = new Department()
                    {
                        DepartmentID = -1, Name = "Virtual Top Department"
                    };
                }

                departmentRepo.Insert(departmentInfo);
                departmentInfo.DeviceAssociations.ForEach(d => d.DepartmentID = departmentInfo.DepartmentID);
                departmentInfo.DeviceAssociations.ForEach(d => departmentDeviceRepo.Insert(d));

                return Request.CreateResponse(HttpStatusCode.OK, departmentInfo);
            }, this));
        }
예제 #6
0
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DUS, () =>
            {
                var userAuthenticationRepo = RepositoryManager.GetRepository <IUserAuthenticationRepository>();
                var userPropertyRepo = RepositoryManager.GetRepository <IUserPropertyRepository>();
                var userRepo = RepositoryManager.GetRepository <IUserRepository>();
                var userDeviceRoleRepo = RepositoryManager.GetRepository <IUserDeviceRoleRepository>();
                var userEventRepo = RepositoryManager.GetRepository <IUserEventRepository>();

                var userInfo = userRepo.GetByKey(id);
                if (userInfo != null)
                {
                    userInfo.UserAuthentications.ForEach(a => userAuthenticationRepo.Delete(a.UserAuthenticationID));
                    userPropertyRepo.Delete(userInfo.UserPropertyInfo.UserPropertyID);
                    userInfo.UserDeviceRoles.ForEach(a => userDeviceRoleRepo.Delete(a.UserDeviceRoleID));
                    userRepo.Delete(id);

                    userEventRepo.Insert(new UserEvent()
                    {
                        EventType = UserEventType.Delete,
                        UserID = userInfo.UserID,
                        CreateDate = DateTime.Now,
                        CreateUserID = GlobalSetting.WebApiUserId,
                    });
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #7
0
        public HttpResponseMessage Post([FromBody] User userInfo)
        {
            return(ActionWarpper.Process(userInfo, OperationCodes.AUS, () =>
            {
                if (userInfo.UserAuthentications == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "UserAuthenticationInfo property cannot be null.");
                }

                if (userInfo.UserPropertyInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "UserPropertyInfo property cannot be null.");
                }

                if (userInfo.UserDeviceRoles == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "UserDeviceRoles property cannot be null.");
                }

                var userAuthenticationRepo = RepositoryManager.GetRepository <IUserAuthenticationRepository>();
                var userPropertyRepo = RepositoryManager.GetRepository <IUserPropertyRepository>();
                var userRepo = RepositoryManager.GetRepository <IUserRepository>();
                var userDeviceRoleRepo = RepositoryManager.GetRepository <IUserDeviceRoleRepository>();
                var userEventRepo = RepositoryManager.GetRepository <IUserEventRepository>();

                if (userRepo.Query(new Hashtable()
                {
                    { "UserCode", userInfo.UserCode }
                }).Any())
                {
                    return new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(string.Format("系统中已经存在编号为{0}的人员", userInfo.UserCode)),
                        ReasonPhrase = ConstStrings.BusinessLogicError,
                    };
                }

                userPropertyRepo.Insert(userInfo.UserPropertyInfo);
                userRepo.Insert(userInfo);

                EncodePassword(userInfo);
                userInfo.UserAuthentications.ForEach(a => a.UserID = userInfo.UserID);
                userInfo.UserAuthentications.ForEach(a => userAuthenticationRepo.Insert(a));

                userInfo.UserDeviceRoles.ForEach(a => a.UserID = userInfo.UserID);
                userInfo.UserDeviceRoles.ForEach(a => userDeviceRoleRepo.Insert(a));

                userEventRepo.Insert(new UserEvent()
                {
                    EventType = UserEventType.Add,
                    UserID = userInfo.UserID,
                    CreateDate = DateTime.Now,
                    CreateUserID = GlobalSetting.WebApiUserId,
                });

                return Request.CreateResponse(HttpStatusCode.OK, userInfo);
            }, this));
        }
예제 #8
0
        public HttpResponseMessage Post([FromBody] DeviceStateHistory deviceStateHistoryInfo)
        {
            return(ActionWarpper.Process(deviceStateHistoryInfo, OperationCodes.ADVDRS, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceStateHistoryRepository>();
                repo.Insert(deviceStateHistoryInfo);

                return Request.CreateResponse(HttpStatusCode.OK, deviceStateHistoryInfo);
            }, this));
        }
예제 #9
0
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DDVRLPMS, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>();
                repo.Delete(id);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #10
0
        public HttpResponseMessage Post([FromBody] SysDictionary sysDictionaryInfo)
        {
            return(ActionWarpper.Process(sysDictionaryInfo, OperationCodes.ASYSDICT, () =>
            {
                var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>();
                repo.Insert(sysDictionaryInfo);

                return Request.CreateResponse(HttpStatusCode.OK, sysDictionaryInfo);
            }, this));
        }
예제 #11
0
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DSYSDICT, () =>
            {
                var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>();
                repo.Delete(id);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #12
0
        // PUT api/customers/5
        public HttpResponseMessage Put(int id, [FromBody] Rld.Acs.Model.TimeZone timeZoneInfo)
        {
            return(ActionWarpper.Process(timeZoneInfo, OperationCodes.MTMZN, () =>
            {
                if (timeZoneInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "timeZoneInfo is null");
                }
                timeZoneInfo.TimeZoneID = id;

                var timeZoneRepo = RepositoryManager.GetRepository <ITimeZoneRepository>();
                var timeZoneGroupRepo = RepositoryManager.GetRepository <ITimeZoneGroupRepository>();
                var timeGroupRepo = RepositoryManager.GetRepository <ITimeGroupRepository>();

                var originalTimeZoneInfo = timeZoneRepo.GetByKey(id);
                if (originalTimeZoneInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("TimeZone Id={0} does not exist.", id));
                }

                if (timeZoneRepo.Query(new Hashtable()
                {
                    { "TimeZoneCode", timeZoneInfo.TimeZoneCode }
                }).Any(x => x.TimeZoneID != id))
                {
                    return new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(string.Format("系统中已经存在编号为{0}的时间区", timeZoneInfo.TimeZoneCode)),
                        ReasonPhrase = ConstStrings.BusinessLogicError,
                    };
                }

                var addedTimeGroups = new List <TimeZoneGroup>();
                var deletedTimeGroupIds = new List <int>();
                if (timeZoneInfo.TimeGroupAssociations != null && timeZoneInfo.TimeGroupAssociations.Any())
                {
                    var originalTimeGroupAssociationIDs = originalTimeZoneInfo.TimeGroupAssociations.Select(d => d.TimeZoneGroupID);
                    var timeGroupAssociationIDs = timeZoneInfo.TimeGroupAssociations.Select(d => d.TimeZoneGroupID);
                    deletedTimeGroupIds = originalTimeGroupAssociationIDs.Except(timeGroupAssociationIDs).ToList();

                    addedTimeGroups = timeZoneInfo.TimeGroupAssociations.FindAll(d => d.TimeZoneGroupID == 0);
                }
                else
                {
                    deletedTimeGroupIds = originalTimeZoneInfo.TimeGroupAssociations.Select(d => d.TimeZoneGroupID).ToList();
                }

                deletedTimeGroupIds.ForEach(d => timeZoneGroupRepo.Delete(d));
                addedTimeGroups.ForEach(d => timeZoneGroupRepo.Insert(d));
                timeZoneInfo.TimeGroupAssociations.FindAll(d => d.TimeZoneGroupID != 0).ForEach(d => timeZoneGroupRepo.Update(d));
                timeZoneRepo.Update(timeZoneInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #13
0
        public HttpResponseMessage Put(int id, [FromBody] Department departmentInfo)
        {
            return(ActionWarpper.Process(departmentInfo, OperationCodes.MDEPT, () =>
            {
                if (departmentInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, "departmentInfo is null");
                }
                departmentInfo.DepartmentID = id;

                var departmentRepo = RepositoryManager.GetRepository <IDepartmentRepository>();
                var departmentDeviceRepo = RepositoryManager.GetRepository <IDepartmentDeviceRepository>();
                var userRepo = RepositoryManager.GetRepository <IUserRepository>();

                var originalDepartmentInfo = departmentRepo.GetByKey(id);
                if (originalDepartmentInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("Department Id={0} does not exist.", id));
                }

                if (originalDepartmentInfo.DeviceRoleID != departmentInfo.DeviceRoleID) // DeviceRole changed
                {
                    var deptUsers = userRepo.Query(new Hashtable()
                    {
                        { "DepartmentID", id }
                    });
                    if (deptUsers.Any())
                    {
                        deptUsers.ForEach(x => UpdateUserDeviceRole(x, originalDepartmentInfo.DeviceRoleID, departmentInfo.DeviceRoleID));
                    }
                }

                var addedDevices = new List <DepartmentDevice>();
                var deletedDevicesIds = new List <int>();
                if (departmentInfo.DeviceAssociations != null && departmentInfo.DeviceAssociations.Any())
                {
                    var originalDeviceAssociationIDs = originalDepartmentInfo.DeviceAssociations.Select(d => d.DepartmentDeviceID);
                    var deviceAssociationIDs = departmentInfo.DeviceAssociations.Select(d => d.DepartmentDeviceID);
                    deletedDevicesIds = originalDeviceAssociationIDs.Except(deviceAssociationIDs).ToList();

                    addedDevices = departmentInfo.DeviceAssociations.FindAll(d => d.DepartmentDeviceID == 0);
                }
                else
                {
                    deletedDevicesIds = originalDepartmentInfo.DeviceAssociations.Select(d => d.DepartmentDeviceID).ToList();
                }

                deletedDevicesIds.ForEach(d => departmentDeviceRepo.Delete(d));
                addedDevices.ForEach(d => departmentDeviceRepo.Insert(d));
                departmentInfo.DeviceAssociations.FindAll(d => d.DepartmentDeviceID != 0).ForEach(d => departmentDeviceRepo.Update(d));
                departmentRepo.Update(departmentInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #14
0
        public HttpResponseMessage Put(int id, [FromBody] SysDictionary sysDictionaryInfo)
        {
            return(ActionWarpper.Process(sysDictionaryInfo, OperationCodes.MSYSDICT, () =>
            {
                sysDictionaryInfo.DictionaryID = id;
                var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>();
                repo.Update(sysDictionaryInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #15
0
        public HttpResponseMessage Put(int id, [FromBody] DeviceStateHistory deviceStateHistoryInfo)
        {
            return(ActionWarpper.Process(deviceStateHistoryInfo, OperationCodes.MDVDRS, () =>
            {
                deviceStateHistoryInfo.DeviceStateHistoryID = id;
                var repo = RepositoryManager.GetRepository <IDeviceStateHistoryRepository>();
                repo.Update(deviceStateHistoryInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #16
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QSYSMDL, () =>
            {
                var repo = RepositoryManager.GetRepository <ISysModuleRepository>();
                var sysModuleInfos = repo.Query(conditions);

                return Request.CreateResponse(HttpStatusCode.OK, sysModuleInfos.ToList());
            }, this));
        }
예제 #17
0
        // GET api/customers
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QTMSGM, () =>
            {
                var repo = RepositoryManager.GetRepository <ITimeSegmentRepository>();
                var timeSegments = repo.Query(conditions);

                return Request.CreateResponse(HttpStatusCode.OK, timeSegments.ToList());
            }, this));
        }
예제 #18
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QDVRLPMS, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>();
                var deviceRolePermissionInfos = repo.Query(conditions);

                return Request.CreateResponse(HttpStatusCode.OK, deviceRolePermissionInfos.ToList());
            }, this));
        }
예제 #19
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QUC, () =>
            {
                var repo = RepositoryManager.GetRepository <IUserRepository>();
                var count = repo.QueryUsersCount(conditions);

                return Request.CreateResponse(HttpStatusCode.OK, count);
            }, this));
        }
예제 #20
0
        public HttpResponseMessage Put(int id, [FromBody] DeviceRole deviceRoleInfo)
        {
            return(ActionWarpper.Process(deviceRoleInfo, OperationCodes.MDVRL, () =>
            {
                deviceRoleInfo.DeviceRoleID = id;

                var deviceRoleRepo = RepositoryManager.GetRepository <IDeviceRoleRepository>();
                var deviceRolePermissionRepo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>();
                var userDeviceRoleRepo = RepositoryManager.GetRepository <IUserDeviceRoleRepository>();

                var originalDeviceRoleInfo = deviceRoleRepo.GetByKey(id);
                if (originalDeviceRoleInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("Device Role Id={0} does not exist.", id));
                }

                var addedPermissions = new List <DeviceRolePermission>();
                var deletedPermissionIds = new List <int>();
                if (deviceRoleInfo.DeviceRolePermissions != null && deviceRoleInfo.DeviceRolePermissions.Any())
                {
                    var originalPermissionIDs = originalDeviceRoleInfo.DeviceRolePermissions.Select(d => d.DeviceRolePermissionID);
                    var currentPermissionIDs = deviceRoleInfo.DeviceRolePermissions.Select(d => d.DeviceRolePermissionID);
                    deletedPermissionIds = originalPermissionIDs.Except(currentPermissionIDs).ToList();

                    addedPermissions = deviceRoleInfo.DeviceRolePermissions.FindAll(d => d.DeviceRolePermissionID == 0);
                }
                else
                {
                    deletedPermissionIds = originalDeviceRoleInfo.DeviceRolePermissions.Select(d => d.DeviceRolePermissionID).ToList();
                }

                if (userDeviceRoleRepo.Query(new Hashtable()
                {
                    { "DeviceRoleID", id }
                }).Any())
                {
                    return new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent("设备角色已经绑定人员使用,不能修改。"),
                        ReasonPhrase = ConstStrings.BusinessLogicError,
                    };
                }

                deletedPermissionIds.ForEach(d => deviceRolePermissionRepo.Delete(d));
                addedPermissions.ForEach(d => deviceRolePermissionRepo.Insert(d));
                deviceRoleInfo.DeviceRolePermissions.FindAll(d => d.DeviceRolePermissionID != 0).ForEach(d => deviceRolePermissionRepo.Update(d));

                deviceRoleRepo.Update(deviceRoleInfo);

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #21
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QSYSOPT, () =>
            {
                var repo = RepositoryManager.GetRepository <ISysOperatorRepository>();
                var operatorInfos = repo.Query(conditions);

                operatorInfos.ForEach(d => d.MaskPassword());
                return Request.CreateResponse(HttpStatusCode.OK, operatorInfos.ToList());
            }, this));
        }
예제 #22
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QUS, () =>
            {
                var repo = RepositoryManager.GetRepository <IUserRepository>();
                var users = repo.Query(conditions);

                users.ForEach(DecodePassword);
                return Request.CreateResponse(HttpStatusCode.OK, users.ToList());
            }, this));
        }
예제 #23
0
        public HttpResponseMessage Get()
        {
            var conditions = ControllerContext.Request.GetQueryNameValueHashtable();

            return(ActionWarpper.Process(conditions, OperationCodes.QUSSMY, () =>
            {
                IEnumerable <User> users = new List <User>();

                var repo = RepositoryManager.GetRepository <IUserRepository>();
                users = repo.QueryUsersForSummaryData(conditions);

                return Request.CreateResponse(HttpStatusCode.OK, users.ToList());
            }, this));
        }
예제 #24
0
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GDVRLPMS, () =>
            {
                var repo = RepositoryManager.GetRepository <IDeviceRolePermissionRepository>();
                var deviceRolePermissionInfo = repo.GetByKey(id);

                if (deviceRolePermissionInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, deviceRolePermissionInfo);
            }, this));
        }
예제 #25
0
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GFL, () =>
            {
                var repo = RepositoryManager.GetRepository <IFloorRepository>();
                var floor = repo.GetByKey(id);

                if (floor == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, floor);
            }, this));
        }
예제 #26
0
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GSYSDICT, () =>
            {
                var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>();
                var sysDictionaryInfo = repo.GetByKey(id);

                if (sysDictionaryInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, sysDictionaryInfo);
            }, this));
        }
예제 #27
0
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GDEPT, () =>
            {
                var repo = RepositoryManager.GetRepository <IDepartmentRepository>();
                var department = repo.GetByKey(id);

                if (department == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, department);
            }, this));
        }
예제 #28
0
        // GET api/customers/5
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GTMZN, () =>
            {
                var repo = RepositoryManager.GetRepository <ITimeZoneRepository>();
                var timeZoneInfo = repo.GetByKey(id);

                if (timeZoneInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK, timeZoneInfo);
            }, this));
        }
예제 #29
0
        public HttpResponseMessage Delete(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.DSYSOPT, () =>
            {
                var sysOperatorRepository = RepositoryManager.GetRepository <ISysOperatorRepository>();
                var sysOperatorRoleRepo = RepositoryManager.GetRepository <ISysOperatorRoleRepository>();
                var sysOperatorInfo = sysOperatorRepository.GetByKey(id);
                if (sysOperatorInfo != null)
                {
                    sysOperatorInfo.SysOperatorRoles.ForEach(x => sysOperatorRoleRepo.Delete(x.SysOperatorRoleID));
                    sysOperatorRepository.Delete(id);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }, this));
        }
예제 #30
0
        public HttpResponseMessage GetById(int id)
        {
            return(ActionWarpper.Process(id, OperationCodes.GUS, () =>
            {
                var repo = RepositoryManager.GetRepository <IUserRepository>();
                var userInfo = repo.GetByKey(id);

                if (userInfo == null)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                DecodePassword(userInfo);
                return Request.CreateResponse(HttpStatusCode.OK, userInfo);
            }, this));
        }