public Lot Save(Lot lot) { if (lot.PkLot > 0) { _fabContext.Lot.Update(lot); _fabContext.SaveChanges(); _lockManager.DeleteTableLock("lot", lot.PkLot); } else { _fabContext.Lot.Add(lot); _fabContext.SaveChanges(); } return(lot); }
public Commentaire AddComment(string tableName, int recordKey, string fieldName, string comment, int isImportant) { Commentaire commentaire = new Commentaire(); commentaire.TableComm = tableName; commentaire.RecordKey = recordKey; commentaire.LastUpdate = DateTime.Now; commentaire.FieldComm = fieldName; commentaire.IsImportant = (isImportant == 1); commentaire.CommentaireHtml = comment; commentaire.UserName = GetUserName(); var tableEntityType = _fabContext.Model.GetEntityTypes().FirstOrDefault(p => p.Name?.Split(".")?.LastOrDefault()?.ToLower() == tableName.ToLower()); if (tableEntityType != null) { var relatedObject = _fabContext.Find(tableEntityType.ClrType, recordKey); commentaire.RecordName = relatedObject?.ToString(); } _fabContext.Commentaire.Add(commentaire); _fabContext.SaveChanges(); return(commentaire); }