//
//  UserMuteExtension.swift
//  WoWonder
//
//  Created by Mohammed Hamad on 06/08/2022.
//  Copyright © 2022 ScriptSun. All rights reserved.
//

import Foundation
import UIKit
import CoreData

extension Mute: CoreDataObject {
    
    convenience init(mute: MuteModel?) {
        self.init(context: CoreDataManager.getInstance().context)
        self.pin = mute?.pin
        self.archive = mute?.archive
        self.call_chat = mute?.call_chat
        self.notify = mute?.notify
        self.fav = mute?.fav
    }
    
    func save() {
        self.setValue(my_id, forKey: #keyPath(Mute.my_id))
        self.setValue(notify, forKey: #keyPath(Mute.notify))
        self.setValue(archive, forKey: #keyPath(Mute.archive))
        self.setValue(fav, forKey: #keyPath(Mute.fav))
        self.setValue(pin, forKey: #keyPath(Mute.pin))
        self.setValue(call_chat, forKey: #keyPath(Mute.call_chat))
        
        do {
            try self.managedObjectContext!.save()
            
        } catch let err {
            print("ERROR \(#file) => \(#function) => \(err.localizedDescription)")
        }
    }
}
