//Insert Data Supplier// public bool insert(TB_M_Supplier supplier) { string Name; Console.Write("Insert Name :"); Name = Console.ReadLine(); TB_M_Supplier suppliers = new TB_M_Supplier(); suppliers.Name = Name; SupplierContext.TB_M_Supplier.Add(suppliers); var result = SupplierContext.SaveChanges(); validation valid = new validation(); return(valid.validate(result)); }
//Update data Item// public bool update(int Id, TB_M_Supplier supplier) { Console.Write("Insert Supplier ID :"); Id = Convert.ToInt16(Console.ReadLine()); var get = SupplierContext.TB_M_Supplier.Find(Id); //var get2 = context.suppliers.singleordefault(x => x.id == id); if (get != null) { string Name; Console.Write("Insert Name:"); Name = Console.ReadLine(); get.Name = Name; SupplierContext.Entry(get).State = EntityState.Modified; var result = SupplierContext.SaveChanges(); validation valid = new validation(); return(valid.validate(result)); } return(status); }