public bool IsThereAPetition() //Devuelve true si ya existe una petición donde se quiere ingresar, false si no. { try { Data.petition res = Connection.AutomateDB.petition.First(re => re.dayoftheweek == Day && re.block == Block && re.infrastructure == Facilty); return(true); } catch (Exception) { return(false); } }
public bool Delete() { try { Data.petition res = Connection.AutomateDB.petition.First(re => re.dayoftheweek == Day && re.block == Block && re.infrastructure == Facilty && re.account == Username); Connection.AutomateDB.petition.Remove(res); Connection.AutomateDB.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool Update() { try { Data.petition res = Connection.AutomateDB.petition.First(re => re.idpetition == Id); res.dayoftheweek = Day; res.block = Block; res.account = Username; res.infrastructure = Facilty; Connection.AutomateDB.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool Read() { try { Data.petition res = Connection.AutomateDB.petition.First(re => re.idpetition == Id); Id = res.idpetition; Day = res.dayoftheweek; Block = res.block; Username = res.account; Facilty = res.infrastructure; return(true); } catch (Exception) { return(false); } }
public bool Create() { try { Data.petition res = new Data.petition(); res.idpetition = LastId() + 1; res.dayoftheweek = Day; res.block = Block; res.account = Username; res.infrastructure = Facilty; Connection.AutomateDB.petition.Add(res); Connection.AutomateDB.SaveChanges(); return(true); } catch (Exception) { return(false); } }