private int DeleteTblBrandSectionPermission(TblBrandSectionPermission row) { using (var context = new WorkFlowManagerDBEntities()) { var oldRow = (from e in context.TblBrandSectionPermissions where e.Iserial == row.Iserial select e).SingleOrDefault(); if (oldRow != null) { context.DeleteObject(oldRow); } context.SaveChanges(); } return(row.Iserial); }
public void SaveMainRow() { if (SelectedBrandSectionPermission != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedBrandSectionPermission, new ValidationContext(SelectedBrandSectionPermission, null, null), valiationCollection, true); if (isvalid) { var save = SelectedBrandSectionPermission.Iserial == 0; var saveRow = new TblBrandSectionPermission(); saveRow.InjectFrom(SelectedBrandSectionPermission); saveRow.BrandCode = SelectedBrand.Brand_Code; saveRow.TblLkpBrandSection = SelectedBrandSection.Iserial; Client.UpdateOrInsertTblBrandSectionPermissionAsync(saveRow, save, PermissionList.IndexOf(SelectedBrandSectionPermission)); } } }
private TblBrandSectionPermission UpdateOrInsertTblBrandSectionPermission(TblBrandSectionPermission newRow, bool save, int index, out int outindex) { outindex = index; using (var context = new WorkFlowManagerDBEntities()) { if (save) { context.TblBrandSectionPermissions.AddObject(newRow); } else { var oldRow = (from e in context.TblBrandSectionPermissions where e.Iserial == newRow.Iserial select e).SingleOrDefault(); if (oldRow != null) { GenericUpdate(oldRow, newRow, context); } } context.SaveChanges(); return(newRow); } }