Exemplo n.º 1
0
        /// <summary>
        /// Function to check if device is assigned to an event.
        /// </summary>
        /// <param name="dId"></param>
        /// <param name="eId"></param>
        /// <returns>True if device is assigned, false otherwise.</returns>
        public Boolean DeviceAssigned(DevicesInEvent d)
        {
            var r = (from x in _repo.GetDevicesInEvents()
                     where x.DeviceId == d.DeviceId & x.EventId == d.EventId
                     select x).Any();

            return(r);
        }
Exemplo n.º 2
0
        public bool RemoveDeviceInEvent(DevicesInEvent d)
        {
            var result = false;

            if (_db.DevicesInEvents.Remove(d) != null)
            {
                result = true;
            }
            _db.SaveChanges();
            return(result);
        }
Exemplo n.º 3
0
        public bool AddDeviceToEvent(DevicesInEvent d)
        {
            var result = false;

            if (_db.DevicesInEvents.Add(d) != null)
            {
                result = true;
            }
            _db.SaveChanges();
            return(result);
        }
Exemplo n.º 4
0
        public async Task <bool> RemoveDeviceInEventAsync(DevicesInEvent d)
        {
            var result = false;

            if (_db.DevicesInEvents.Remove(d) != null)
            {
                result = true;
            }
            await _db.SaveChangesAsync();

            return(result);
        }
Exemplo n.º 5
0
        public async Task <bool> AddDeviceToEventAsync(DevicesInEvent d)
        {
            var result = false;

            if (await _db.DevicesInEvents.AddAsync(d) != null)
            {
                result = true;
            }
            await _db.SaveChangesAsync();

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Function to assign device to an event.
        /// </summary>
        /// <param name="dId"></param>
        /// <param name="eId"></param>
        /// <returns>Returns instance of the assignment.</returns>
        public async Task <DevicesInEvent> AddDeviceInEventAsync(int dId, int eId)
        {
            var d = new DevicesInEvent {
                DeviceId = dId, EventId = eId
            };

            if (DeviceAssigned(d) == false)
            {
                await _repo.AddDeviceToEventAsync(d);

                return(d);
            }
            else
            {
                var n = await GetDeviceByIdAsync(dId);

                throw new Exception(n.Name + " is already assigned to this event");
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Function to unassign device from event.
 /// </summary>
 /// <param name="d"></param>
 /// <returns>True if success, false otherwise.</returns>
 public async Task <Boolean> RemoveDeviceInEventAsync(DevicesInEvent d)
 {
     return(await _repo.RemoveDeviceInEventAsync(d));
 }