public static int AddRoomDeviceTimeOn(DeviceOnTime reg)
 {
     using (HomeAutomationEntities context = new HomeAutomationEntities())
     {
         context.DeviceOnTime.Add(reg);
         int result = context.SaveChanges();
         return(result);
     }
 }
 public static int UpdateRoomDeviceTimeOn(DeviceOnTime reg)
 {
     using (HomeAutomationEntities context = new HomeAutomationEntities())
     {
         context.DeviceOnTime.Attach(reg);
         context.Entry(reg).State = EntityState.Modified;
         int result = context.SaveChanges();
         return(result);
     }
 }
Example #3
0
 public DeviceOnTimeDTO(DeviceOnTime register)
 {
     this.RoomDeviceID   = register.RoomID;
     this.RoomID         = register.RoomID;
     this.OnTime         = register.OnTime;
     this.OffTime        = register.OffTime;
     this.OnTimeDuration = register.OnTimeDuration;
     this.OnUserID       = register.OnUserID;
     this.OffUserID      = register.OffUserID;
 }
Example #4
0
        /// <summary>
        /// Updates the device status.
        /// </summary>
        /// <param name="roomId">The room identifier.</param>
        /// <param name="selectedDeviceID">The selected device identifier.</param>
        /// <param name="buttonState">if set to <c>true</c> [button state].</param>
        /// <returns></returns>
        /// <Author> Daniel Molina </Author>
        /// <LastModification>  29/11/2017 - 16:20 </LastModification>
        /// <LastModificationBy> Daniel Molina </LastModificationBy>
        public static RoomDeviceResponse UpdateDeviceStatus(int roomId, int selectedDeviceID, bool buttonState)
        {
            try
            {
                //Validate the Device Status
                List <GetDeviceByRoomIdAndDeviceID_Result> lstDeviceByRoomIdAndDeviceId = DeviceController.GetDeviceByRoomIdAndDeviceId(roomId, selectedDeviceID);
                List <DevicesDTOPartial> retVal = new List <DevicesDTOPartial>();
                foreach (GetDeviceByRoomIdAndDeviceID_Result reg in lstDeviceByRoomIdAndDeviceId)
                {
                    retVal.Add(new DevicesDTOPartial(reg));
                }

                //Validate that the device State
                if (retVal[0].State == buttonState)
                {
                    Logger.Logger.Info(profileName, "Method Response: The device has the same status. Username:"******"PasswordRetriesListByUtilityID", "Endpoint not found exception", ex);
                return(new RoomDeviceResponse {
                    Code = (int)ResponseCode.Exception, Message = ResponseCode.Exception.ToString() + ": " + ex.Message
                });
            }
        }