public static bool Insert(int UserID, int VendorID) { try { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { PL.TblVendorEmployee newRow = new TblVendorEmployee() { ID = rc.TblVendorEmployees.Any() ? rc.TblVendorEmployees.Max(u => u.ID) + 1 : 1, UserID = UserID, VendorID = VendorID }; rc.TblVendorEmployees.Add(newRow); rc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public static bool Update(VendorEmployeeModel vendorEmployee) { try { if (vendorEmployee.ID != 0) { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { TblVendorEmployee tblVendorEmployee = rc.TblVendorEmployees.FirstOrDefault(u => u.ID == vendorEmployee.ID); if (tblVendorEmployee != null) { tblVendorEmployee.ID = vendorEmployee.ID; tblVendorEmployee.UserID = vendorEmployee.UserID; tblVendorEmployee.VendorID = vendorEmployee.VendorID; rc.SaveChanges(); return(true); } else { throw new Exception("VendorEmployee was not found"); } } } else { throw new Exception("Must have a valID ID"); } } catch (Exception ex) { throw ex; } }