public bool updateProducer(int id, Producer p, int adminid) { var db = new DatabaseContext(); try { Producers prod = db.Producers.FirstOrDefault(pr => pr.Id == id); prod.Id = id; prod.Name = p.name; db.SaveChanges(adminid); return(true); } catch (Exception e) { writeToFile(e); return(false); } }
public bool AddProducer(Producer producer, int id) { var newProducer = new Producers() { Name = producer.name }; try { var db = new DatabaseContext(); db.Producers.Add(newProducer); db.SaveChanges(id); return(true); } catch (Exception fail) { writeToFile(fail); return(false); } }
public Producer producerDetails(int id) { try { var db = new DatabaseContext(); Producers produser = (Producers)db.Producers.FirstOrDefault(c => c.Id == id); Producer prod = new Producer() { id = produser.Id, name = produser.Name }; return(prod); } catch (Exception e) { writeToFile(e); return(null); } }
public bool AddProducer(Producer producer, int id) { var newProducer = new Producers() { Name = producer.name }; try { var db = new DatabaseContext(); db.Producers.Add(newProducer); db.SaveChanges(id); return true; } catch (Exception fail) { writeToFile(fail); return false; } }