public int UpdateCategory(int input) { System.Console.Write("Category Name : "); string catnames = System.Console.ReadLine(); Console.WriteLine("\n"); Console.WriteLine("============================================="); System.Console.Write("MASUKKAN ULANG ID : "); int id_cat = Convert.ToInt32(System.Console.ReadLine()); var getmhs = hld_context.Category_s.Find(id_cat); if (getmhs == null) { System.Console.Write("TIDAK ADA ID CATEGORY : " + id_cat); } else { CategoryCls ct = GetByid(input); ct.ID = id_cat; ct.Category_Name = catnames; hld_context.Entry(ct).State = System.Data.Entity.EntityState.Modified; hld_context.SaveChanges(); } return(input); }
// =========================================== INSERT ============================================= public void InsertCategory() { Console.Clear(); System.Console.Write("Category Name : "); string catname = System.Console.ReadLine(); CategoryCls call = new CategoryCls(); { call.Category_Name = catname; }; try { hld_context.Category_s.Add(call); var result = hld_context.SaveChanges(); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }