public static Common.Models.Assets.Version Create( Common.Models.Assets.Version model, Common.Models.Account.Users creator, IDbConnection conn = null, bool closeConnection = true) { if (!model.Id.HasValue) { model.Id = Guid.NewGuid(); } model.CreatedBy = model.ModifiedBy = creator; model.Created = model.Modified = DateTime.UtcNow; DBOs.Assets.Version dbo = Mapper.Map <DBOs.Assets.Version>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("INSERT INTO \"version\" (\"id\", \"sequence_number\", " + "\"change_details\", \"asset_id\", " + "\"utc_created\", \"utc_modified\", \"created_by_user_pid\", \"modified_by_user_pid\") " + "VALUES (@Id, @SequenceNumber, @ChangeDetails, @AssetId, @UtcCreated, @UtcModified, @CreatedByUserPId, @ModifiedByUserPId)", dbo); DataHelper.Close(conn, closeConnection); return(model); }
public static Common.Models.Assets.Version Edit( Common.Models.Assets.Version model, Common.Models.Account.Users modifier, IDbConnection conn = null, bool closeConnection = true) { model.ModifiedBy = modifier; model.Modified = DateTime.UtcNow; DBOs.Assets.Version dbo = Mapper.Map <DBOs.Assets.Version>(model); conn = DataHelper.OpenIfNeeded(conn); conn.Execute("UPDATE \"version\" SET " + "\"change_details\"=@ChangeDetails, " + "\"utc_modified\"=@UtcModified, \"modified_by_user_pid\"=@ModifiedByUserPId " + "WHERE \"id\"=@Id", dbo); DataHelper.Close(conn, closeConnection); return(model); }